Pd OSC ints > Processing > Arduino > shif

Hi Paul,

Thanks again for the point in the right direction! I think I am almost there... trying to adapt a bit of AWOL's code from another post to mine but it seems to be concatenating values through the serial monitor. if i type a 1 first its fine... if i then type 33 the next number is 13... then a 3 will pop up. Any ideas on where I'm going wrong?

Code:

char val [10];
int index = 0;

void loop() {
long now = millis();
if (Serial.available() > 0) {
inByte = Serial.read();
// if (now % 1000){
val[index++] = inByte;
val[index] = '\0';
int a = atoi(val);
Serial.println(a);
if (a > 0 && a < 60){
fadeall(50,1023,0,0,0,0,1023); //from red to blue
}
else if (a > 60){
fadeall(50,0,0,1023,1023,0,0); //from blue to red
}
else {
}
if (inByte <= '0' || inByte >= '9') {
index = 0;
}
a = 0;
//Serial.flush();
// }
}
}