Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (24 sloc) 815 Bytes
// Sweep Servo Test
#include <Servo.h>
Servo myservo1; // servo object
// up to eight servo objects total
int pos = 0; // store the servo position
int posMin = 0; // min postion
int posMax = 180; // max position - different servos have different ranges
void setup()
{
myservo1.attach(3); // attaches the servo on pin 3
}
void loop()
{
for(pos = posMin; pos < posMax; pos += 1) // goes from posMin degrees to posMax degrees
{
myservo1.write(pos); // update variable with postion
delay(15); // waits 15ms
}
for(pos = posMax; pos >= posMin; pos-=1) // goes from posMax degrees to posMin degrees
{
myservo1.write(pos); // update variable with postion
delay(15); // waits 15ms
}
}