Arduino code: continuous servo triggered by button

//source http://madrid.verkstad.cc/en/course-literature/continuous-rotation-servo/

#include <Servo.h>

Servo myservo;

void setup() {
myservo.attach(9);
pinMode(2, INPUT);

}

void loop() {
if(digitalRead(2) == HIGH){

myservo.write(45); //you must find the absolute # that stops the servo motion
delay(1000);
myservo.write(100);
delay(1000);
}
else{
digitalWrite(9, LOW);

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *