Can I send two separate data values through the serial port from Arduino to processing?

Rick H. William's picture

Offline

Joined: Nov 27, 2019

Replies: 6
Can I send two separate data values through the serial port from Arduino to processing?
December 2, 2019 - 1:30am

I am creating a project similar to this https://circuitdigest.com/microcontroller-projects/ping-pong-game-using-arduino-accelerometer#comment-30863 

I currently am using Serial.write to send the accelerometer data values over the serial port to processing. I would like to introduce a button (digtal reading) where if the button is pressed the data can be read by processing and without affecting any of the accelerometer data being read. How could I do that?

Aswinth Raj's picture

Offline

Joined: Aug 16, 2016

Replies: 947
Yes you can
December 2, 2019 - 12:58pm

The communication protocol between your Arduino and Processing is called "Serial communication". It has a separate line for Rx and Tx, so you can also send values from processing to Arduino sketch. You simply have to use the write() funtion on processing code when the button is pressed. This link can help 

https://forum.processing.org/two/discussion/17597/processing-to-arduino-serial