Communications between Processing and Arduino IDE

Hello everyone, I am trying to learn how to communicate between my Processing application and my Arduino code together. I want to ask a simple question and that is, is it possible to use the exact same variable name with the same intended function on both sides.?

For eg :
In my processing, i have an int ‘x’ which is programmed to constantly check the output and update itself when the output changes.

is there a way i can use this same int ‘x’ in my Arduino program too, to display on the Serial monitor the ’ output from my processing '.?

Though i know i can also display through the processing, but if for eg i want those data taken from the processing and display on the Serial Monitor of the Arduino. Is it possible to link the processing and Arduino together and use that common ’ int x '.?

ha, the two IDE might look alike,
but the code you made with it is very different
and can never run on the same computer.
also the projects and source code are well separated.

so not worry about that, yes it might even be good to use that same names,
( just not to confuse yourself )

usually if you setup a communication between a
arduino – USB – processing program
you send from arduino, like after measuring Ain’s…
astring = A0+","A1 …
and Serial.println(astring);

1023,1023,1023....

what is fast, readable, but requires good documentation…( what means what )

but if your application is not time critical you could even send full text
including the variable names you mentioned.
that could be of type JSON record.
and i made a ready example here already for that communication.
Good practice for sending data from Arduino to Processing - #5 by kll
click on

example v02

to get the code for both sides.

1 Like