/*
ArdBot ServoTest
Tests servos of robot by moving them in different directions
Requires Arduino IDE version 0017 or later
(0019 or later preferred)
*/
#include
Servo servoLeft; // Define left servo
Servo servoRight; // Define right servo
void setup()
{
servoLeft.attach(10); // Set left servo to digital pin 10
servoRight.attach(9); // Set right servo to digital pin 9
}
void loop() // Loop through motion tests
{
forward(); // Example: move forward
delay(2000); // Wait 2000 milliseconds (2 seconds)
reverse();
delay(2000);
turnRight();
delay(2000);
turnLeft();
delay(2000);
stopRobot();
delay(2000);
}
// Motion routines for forward, reverse, turns, and stop
void forward()
{
servoLeft.write(0);
servoRight.write(180);
}
void reverse()
{
servoLeft.write(180);
servoRight.write(0);
}
void turnRight()
{
servoLeft.write(180);
servoRight.write(180);
}
void turnLeft()
{
servoLeft.write(0);
servoRight.write(0);
}
void stopRobot()
{
servoLeft.write(90);
servoRight.write(90);
}