Skip to content
Oliver Steele edited this page Oct 25, 2022 · 1 revision

Once the SerialRecord for Processing library has been installed, examples are available from the Processing application's File > Examples menu.

You may also review the examples on GitHub.

List of Example Sketches

  • ReceiveSingleValue — expects each record to consist of a single value between 0 and 1023. This value is scaled to the height of the window, and used as the height of a single line that is drawn in the window.
  • ReceiveMultipleValues – expects each record to include two values between 0 and 1023. These values are scaled to the window width and height, respectively, and used to position a circle.
  • SendSingleValue — transmit a record consisting of a single value on the serial port. If the mouse button is held down while the mouse is over the running Processing sketch window, a one is transmitted; otherwise, a zero is transmitted.
  • SendMultipleValues — scales the x and y components of the mouse position to values between 0 and 1023, and transmits these on the serial port.
  • SendMultipleValuesRequestEcho (added in library version 0.3.1) – this sketch is identical to SendMultipleValues, except that it additionally demonstrates the echo request feature. Click anywhere in the run window in order to request the Arduino to send back the last values that it received. (You may have to click twice: once to focus the window, and once to send a click within the window to the running Processing sketch.) This value is displayed in the Processing sketch's run window, next to the RX (receive) label.
  • SendMultipleValuesPeriodicEcho (added in library version 0.3.1) – this sketch is identical to SendMultipleValues, except that it additionally demonstrates the periodic echo request feature. The Processing sketch automatically requests and echo from the Arduino every 1000 milliseconds (one second).
  • SendReceiveMultipleValues — transmits pairs of values (the mouse x and y positions) to the Arduino, receives records of three values, uses the first two values to position a red circle, and ignores the third. When used with the SerialRecord for Arduino sketch, the first two values that Processing receives from the serial port are the two values that it sent, in the opposite order.

Each example is designed to pair with an example in the SerialRecord library for Arduino library.

SerialRecord example connections

The examples can also be used with other Arduino sketches (so long as those sketches are written to send or receive to expected number of values), or as a starting point for your own work.

Note: If the examples don't run, see whether the behavior that you see matches one of the symptoms on the Troubleshooting page.

Note: Remember to make a copy of an example before you modify it. The Processing IDE (unlike the Arduino IDE) will not do this for you.

Clone this wiki locally