// Sweep // by BARRAGAN #include Servo myservo1; // create servo object to control a servo // a maximum of eight servo objects can be created Servo myservo2; int pos = 0; // variable to store the servo position int serial1 = 0; int serial2 = 0; byte motor=0; byte value1=0; byte value2=0; void setup() { myservo1.attach(9); // attaches the servo on pin 9 to the servo object myservo2.attach(10); Serial.begin(115200); } void loop() { if(Serial.available() > 2) { motor = Serial.read(); if (motor == 1){ value1 = Serial.read(); value2 = Serial.read(); serial1=value1*255+value2; } if (motor == 2){ value1 = Serial.read(); value2 = Serial.read(); serial2=value1*255+value2; } } myservo1.writeMicroseconds(serial1); myservo2.writeMicroseconds(serial2); }