Hello,
Welcome to the community!
Try this for Arduino code for testing:
boolean toggle = false;
void setup()
{
Serial.begin(9600);
}
void loop()
{
long total1 = 271828182;
long total2 = 314159265;
if (toggle)
{
Serial.print(0);
Serial.print(',');
Serial.println(total1);
}
else
{
Serial.print(1);
Serial.print(',');
Serial.println(total2);
}
delay(1000);
toggle = !toggle;
}
You are sending a long as a String so receive as a String for now; you are converting to an int in your code.
String sensors[] = split(myString, ',');
My processing code (modified yours a bit) was able to receive “sensor number” and “data” and print with:
sensor1 = int(sensors[0]);
println(sensor1);
long data = Long.parseLong(sensors[1]);
println(data);
I then displayed a circle() to keep it simple and changed color depending on “sensor number”.