Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myServo; // Declare a servo object for us to control
- int servoPin = 9; // Var for the pin the servo connects to
- int pos = 0; // Var to keep track of the servo's position
- void setup() {
- myServo.attach(servoPin); //Tell the servo to what pin it's connected to
- }
- void loop() {
- for(pos = 0; pos < 50; pos += 1){
- myServo.write(pos);
- delay(15);
- }
- for(pos = 50; pos < 100; pos += 5){
- myServo.write(pos);
- delay(15);
- }
- for(pos = 200; pos < 160; pos += 1){
- myServo.write(pos);
- delay(15);
- }
- for(pos =360; pos>=1; pos -= 20){
- myServo.write(pos);
- delay(15);
- }
- }
Add Comment
Please, Sign In to add comment