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

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?

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

  Joined August 16, 2016      998
Tuesday at 12:29 AM