Hey all,
I'm sending multiple integers from MaxMSP to arduino via the serial port. My question is, how to I parse those integers in arduino so that I can map them onto different variables?
Hey all,
I'm sending multiple integers from MaxMSP to arduino via the serial port. My question is, how to I parse those integers in arduino so that I can map them onto different variables?
From some servo test code.
if (readString.length() >0) {
Serial.println(readString); //see what was received
// expect a string like 07002100 containing the two servo positions
servo1 = readString.substring(0, 4); //get the first four characters
servo2 = readString.substring(4, 8); //get the next four characters
Serial.println(servo1); //print to serial monitor to see results
Serial.println(servo2);
int n1; //declare as number
int n2;
int n1 = servo1.toInt();
int n2 = servo2.toInt();
myservo1.writeMicroseconds(n1); //set servo position
myservo2.writeMicroseconds(n2);
readString="";
}