Advertisement
pleasedontcode

"Servo Control" rev_01

Jan 12th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Servo Control"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-12 14:55:33
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Rotate servo motor , using iot */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <Servo.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF PWM OUTPUT PINS *****/
  32. const uint8_t Opener_Servomotor_PWMSignal_PIN_D3 = 3;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. Servo myservo;
  36.  
  37. void setup(void)
  38. {
  39.   // put your setup code here, to run once:
  40.   pinMode(Opener_Servomotor_PWMSignal_PIN_D3, OUTPUT);
  41.  
  42.   myservo.attach(Opener_Servomotor_PWMSignal_PIN_D3);
  43. }
  44.  
  45. void loop(void)
  46. {
  47.   // put your main code here, to run repeatedly:
  48.  
  49.   // Rotate the servo motor
  50.   for (int pos = 0; pos <= 180; pos += 1) {
  51.     myservo.write(pos);
  52.     delay(15);
  53.   }
  54.   for (int pos = 180; pos >= 0; pos -= 1) {
  55.     myservo.write(pos);
  56.     delay(15);
  57.   }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement