/* Program to control a servo motor by LauchPad. * The servo motor control uses pin 39. * Although the 0 to 180 degree rotation limits are mapped to * 1000 us and 2000 us, actual motor varies. * * This program uses Servo library. For details of libraries: * http://energia.nu/reference/libraries/ * * Energia 1.6.10E18 */ #include const int servoControl = 39; Servo motor; // create servo object to control a motor void setup() { // This sets up 39 for servo control. motor.attach(servoControl, 1000, 2000); // attaches the servo control on pin 39 // 1000 us and 2000 us are the limits for 0 to 180 degree rotation. } void loop() { for (int pw = 0; pw < 180; pw+=5) // clockwise rotation { motor.write(pw); // sets the servo position delay(100); } for (int pw = 180; pw > 0; pw-=5) // counterclockwise rotation { motor.write(pw); // sets the servo position delay(100); } }