Digital Etch-A-Sketch by Mattias Green

A simple but effective project to demonstrate physical control over a computer screen.

  1. Connect two potentiometers to Arduino analog inputs A0 and A1
  2. Use serial-communications to get pot values from Arduino to Processing
  3. Make a Processing sketch that accepts the serial data and draws lines

 Arduino Code

Please take a moment to think about how the variable values will be presented to Processing. You cannot just Serial.println(var1); Serial.println(var2); If you’d do that, there would be no way for processing to know which value comes from which variable. To help parsing the data in Processing, print the values on the same line, separated by a comma.

Now, processing will se your two values like this: 233,856 and they will be considered a text String, not numeric values. (233 would be the value at Arduino pin A0 and 856 at A1.) You can easily convert such a string of words delimited by commas into an array of words.  Use  split(str,delimiter) in Processing. “233,856” will be converted to [“233”, “856”] and each item can be accessed individually, and treated as a numeric value.

Processing Code

 

Proof of Concept ;)

(Does not work in Firefox for some WordPress-related reason)