(First of all, I’ve tried to train myself to refer to the data sent over the serial port as ‘command codes’ but I always find myself lapsing into calling them ‘control codes.’ So I give up for today.)
Here’s what I send from processing:
int outgoingbyte = 125; myPort.write(outgoingbyte); for (int i = 1; i<=cnum; i++){ seg_calc(i); println(str(i-1)+"."+str(cc1)+"."+str(cc2)+"."+str(cc3)+"."+str(cc4)); myPort.write(cc1); myPort.write(cc2); myPort.write(cc3); myPort.write(cc4); } outgoingbyte = 126; myPort.write(outgoingbyte);
And here’s how the Arduino receives it:
if (Serial.available() < 1) { return; } digitalWrite(13,HIGH); incomingByte = Serial.read(); /* if (incomingByte == 125){ digitalWrite(13,HIGH); delay(5000); cc_count = 0; } if (incomingByte == 126) { digitalWrite(13,LOW); } cc_count = cc_count + 1; cc_list[cc_count] = incomingByte; */
As you can see, I commented out most of the code here because it wasn’t working and I needed to test it. What the uncommented code does is turn on the pin 13 LED to confirm when serial data is received. And yes, the LED went ON, so I know that data is coming over.
Originally, however, the code was written to turn on the pin 13 LED when a value of 125 (= BOF = Beginning Of File) is received and turn off the pin 13 LED when a value of 126 (= EOF = End of File) is received. It wasn’t doing that.
So where am I? I know that data is going over the serial port, but apparently it’s not being read the same way it was written. Now I need to find out why, or find a way to work around the problem.