LED-Matrix - Interrupt equalizer for a single command

Hey all!

Currently I am working on a small LED-Matrix and it is already working the way I want. I start an processing sketch that analyzes the music that is playing on the computer and sends data nonstop to my led-panel. Something similar like this:

My processing sketch sends 7 bytes to my arduino with every cycle (for example: 1202014) The arduino receives the bytes with this code:

void readSerial(){
  if (Serial.available() > 6) {
      bar1 = Serial.read()-48;
      bar2 = Serial.read()-48;
      bar3 = Serial.read()-48;
      bar4 = Serial.read()-48;
      bar5 = Serial.read()-48;
      bar6 = Serial.read()-48;
      bar7 = Serial.read()-48;
  }
}

This is working so far. But now I want to be able to change the color while the animation is running. How can I make sure that these commands won't mix up? I want to send something like "C255000100" (Color,R,G,B) to the arduino.

Any ideas?

Thanks

You have to establish a protocol. Define commands for display update, color change and every other action you want the Arduino to execute. Commands can be single characters (fast) or complete words (better human readable), you decide. To make it more robust, define a start character and an end character for a complete message.

I want to send something like “C255000100” (Color,R,G,B) to the arduino.

Sending something like “<255, 0, 100>” would be far easier to deal with, if you really are sending strings. Sending binary data is faster, and speed seems like it would be useful for your application.