Advertisement
LeventeDaradici

Servo in arduino - only servo

Dec 29th, 2021
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1.  
  2. // Include the Servo library
  3. #include <Servo.h>
  4. // Declare the Servo pin
  5. int servoPin = 3;
  6. // Create a servo object
  7. Servo Servo1;
  8. void setup() {
  9. // We need to attach the servo to the used pin number
  10.    Servo1.attach(servoPin);
  11. }
  12. void loop(){
  13. // Make servo go to 0 degrees
  14.    Servo1.write(0);
  15.    delay(1000);
  16. // Make servo go to 90 degrees
  17.    Servo1.write(90);
  18.    delay(1000);
  19. // Make servo go to 180 degrees
  20.    Servo1.write(180);
  21.    delay(1000);
  22. // Make servo go to 90 degrees
  23.    Servo1.write(90);
  24.    delay(1000);
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement