Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include the Servo library
- #include <Servo.h>
- // Declare the Servo pin
- int servoPin = 3;
- // Create a servo object
- Servo Servo1;
- void setup() {
- // We need to attach the servo to the used pin number
- Servo1.attach(servoPin);
- Serial.begin(9600);
- }
- void loop(){
- for(int i = 45; i <= 135; i=i+2)
- {Servo1.write(i);
- Serial.println(i);
- delay(100);
- }
- for(int i = 135; i >= 45; i=i-2)
- {Servo1.write(i);
- Serial.println(i);
- delay(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement