Sunday, December 20, 2009

simple servo control codes [last saturday] 001

//for this code you'll need a servo conected to PIN2

//remember to load a library for servo control!

Servo myServo;//creates servo object to play with

void setup(){
myServo.attach(2);//defines where the servo is attached
}

void loop(){//repeats that:

myServo.write(0);//turns the servo to its 0 positioon
delay(500);//waits 500 ms
myServo.write(180);//turns the servo 180 degrees
delay(500);//waits again
}

No comments:

Post a Comment