How to recieve multiples values from Touch to Arduino (serial port)

Hi!

I’m mapping an Arduino Esplora via serial in Touchdesigner.

For send from Arduino it’s very easy to send different values at the same time with the Serial.println() function.

But how I recieve multiple data FROM touchdesigner to Arduino? At the moment I can recieve one value with serial.read() function. But i don’t know how to recieve multiple values from Touchdesigner.

#include <Esplora.h>

int serialByteRecieve = 0;

void setup() {
// initialize the serial communication:
Serial.begin(9600);
}

void loop() {

// send data only when you receive data:

if (Serial.available() > 0) {
// read the incoming byte:
serialByteRecieve = Serial.read();

// write the value coming from touchdesigner to the rgb led:

Esplora.writeRed(serialByteRecieve);
Esplora.writeGreen(serialByteRecieve);

}

esplora mapping.9.toe (4.5 KB)

Thanks a lot in advance,

joan nosebleed

You can do many things…
Firs of all try to read arrays and not a single byte:

One is to send a packet of bytes each time, and firs byte is a control digit that says to arduino which color is sent.
Other is you can encapsulate firs and second value in a single number lige this:
Admiting that R and G values are form 0 to 255
number to send = R*256+G
decoding:
R=int(number received/256)*256
G=number received - R