Advertisement
LeventeDaradici

Servo 90 degrees sliding 2

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