#include Servo servoMotorA; // creates an instance of the servo object to control a servo Servo servoMotorB; // creates an instance of the servo object to control a servo int pos = 0; // variable to store the servo position int analogPin = 0; // the analog pin that the sensor is on int analogValue = 0; int servoPinA = 9; // Control pin for servo motor, may only be pin 9 or 10 int servoPinB = 10; // Control pin for servo motor, may only be pin 9 or 10 void setup() { servoMotorA.attach(servoPinA); // attaches the servo on pin 2 to the servo object servoMotorB.attach(servoPinB); // attaches the servo on pin 3 to the servo object Serial.begin(9600); Serial.println("Dream weaver II!"); } void loop() { if (Serial.available() > 0) { int dataIn = Serial.read(); switch(dataIn) { case '1': for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree servoMotorA.write(pos); // tell servo to go to position in variable 'pos' delay(.005); // waits 15ms for the servo to reach the position } for(pos = 0; pos = 0;); // doesnt go anywhere,waits for the first motor to reach there { // in steps of 1 degree servoMotorB.write(pos); // tell servo to go to position in variable 'pos' delay(.005); // waits 15ms for the servo to reach the position } break; case '2': for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees { servoMotorA.write(pos); // tell servo to go to position in variable 'pos' delay(.005); // waits 15ms for the servo to reach the position } for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree servoMotorB.write(pos); // tell servo to go to position in variable 'pos' delay(.005); // waits 15ms for the servo to reach the position } } } }