import processing.serial.*;
Serial port;
String data = "";
String Power = "No Connect !";
int index_Power = 0;
int index_Alarme =0;
void setup()
{
background(0,0,0);
size(600,400);
port = new Serial(this, "COM11", 57600);
port.bufferUntil('.');
}
void draw()
{
Etat_Arduino(Power,112,103); //print : "ERROR !" instead of "OK !"
fill(46, 209, 2);
text(Power, 70, 320); //print : "1"
}
void serialEvent (Serial port)
{
data = port.readStringUntil('.');
data = data.substring(0, data.length() - 1);
index_Power = data.indexOf(",");
Power = data.substring(0, index_Power );
}
void Etat_Arduino(String V,int X,int Y)
{
if (V == "1")
{
text("OK !",X,Y);
}
else
{
text("ERROR !",X,Y);
}
}
I would also like to change the variable that the program of the arduino send me, for example, it sent me "Power = 1" and I want to "Power = 0" so I sent it 0, and I will add another variables, how can I do for the arduino to receive. and processing sent it?