#include #include VarSpeedServo myservo1,myservo2,myservo3,myservo4,myservo5,myservo6; int sspd = 40; // Set movement speed 1-255 String command; // String input from command prompt String temp1,temp2; // temporary strings char inByte; // Byte input from command prompt char arrAngles[2]; // character array for string to int // manipulation void setup() { Serial.begin(9600); myservo1.attach(3); myservo2.attach(5); myservo3.attach(6); myservo4.attach(9); myservo5.attach(10); myservo6.attach(11); // Set each servo to start posn myservo1.write(90,255,true); // Set brg (wait to complete true-false) myservo2.write(65,255,true); // Set elev myservo3.write(90,255,true); myservo4.write(65,255,true); myservo5.write(90,255,true); myservo6.write(65,255,true); } void loop(){ int x = 0; char a; int y; if(Serial.available() > 0) { inByte = Serial.read(); command.concat(inByte); } if (inByte == 10 || inByte == 13){ inByte = 0; char gNum = command.charAt(0); for(x = 2;x < command.length(); x++){ a = command.charAt(x); if(a != ' '){ temp1.concat(a); }else{ break; } } for(x = x + 1;x < command.length(); x++){ a = command.charAt(x); if(a != ' '){ temp2.concat(a); }else{ break; } } if (gNum == '1'){ myservo1.write(temp1.toInt(),sspd,false); myservo2.write(temp2.toInt(),sspd,false); } if (gNum == '2'){ myservo3.write(temp1.toInt(),sspd,false); myservo4.write(temp2.toInt(),sspd,false); } if (gNum == '3'){ myservo5.write(temp1.toInt(),sspd,false); myservo6.write(temp2.toInt(),sspd,false); } command = ""; temp1 = ""; temp2 = ""; } }