for(int i=0; i < 5; i++) {
inData[i] = Serial.read();
}
inData[i] = '\0'; // terminate the string
Okay, I did what you said, but if I do this, nothing works. It's like inData is cleared before I can do anything else.
If I put,
if(Serial.available() >0) {
for(int i=0; i<5; i++) {
inData[i] = Serial.read();
}
inData[5] = '\0';
Serial.println(inData);
}
I get junk output if I echo what is read in. For example, if I send the command "right," I can get r???? or ight? or ri??? or any other combination of something that resembles "right" but replaces some letter with ?. This happens on both the XBee and USB.