Displayduino control via Serial

If you're always sending 3 chars per number then technically there's no need for a delimiter, still no point changing things.

I'd replace

getSerial();
red = serialdata;

with

red = getSerial();

just looks neater but won't have any real affect on performance.

is there an easier way to do this?

There are other ways but I'm not sure in this case it's worth persuing them. For example you could just send 7 binary values plus a delimiter, that way you just have

byte data[5];

if (Serial.available()) {
   if (Serial.read() == 'x') // ignore data until the delimiter
      for (int i = 0, i < 5; i++)
         data[i] Serial.read();
}

switch (data[0]) { // switch on the board #
// etc etc
// it's not clear what you are doing with the data
}

The only thing here is selecting the delimiter value as (presumably) all values are valid data. Maybe use 255 and limit the colours to 0-254. Or don't bother with a delimiter but then you can get out of phase if you miss a character.


Rob