Visualizing real-time data
Arduino is a small electronic board with a microcontroller, developed by members of the Interaction Design Institute in Ivrea. The name is derived from that of a Ivrea bar frequented by some of the founders of the project (which in turn calls the name of Arduino d'Ivrea, King of Italy in 1002).
Arduino uses sensors (for example, a light sensor) and actuators (for example a motor) that allow to hear and act on the real world.
It is equipped with a simple integrated development environment for programming with a simple and intuitive language derived from C and C++ called Wiring (much like Processing).
In this part we will integrate Arduino and Processing in order to visualize data coming in real-time from the real world:
- Hardware. Components are: photoresistor, potentiometer, piezo, button. The circuit is as follows:
- photoresistor: one terminal to power (5V), one terminal to ground (GND) with 10K resistor and to analogic pin A0;
- potentiometer: one terminal to power (5V), one terminal to ground (GND), central terminal to analogic pin A1;
- piezo: one terminal to ground (GND) and one terminal to digital pin 8;
- button: one terminal to power (5V), one terminal to ground (GND) with a 10K resistor and to digital pin 2.
-
Communication protocol. The communication protocol between Arduino and Processing on the serial port is described as follows. Arduino tries the first contact with Processing by sending a byte on the serial port (first contact). When Processing receives the first contact responds by sending a byte on the serial port (ready). Arduino then receives the response and sends the values of the photoresistor, potentiometer and the status of the button (send values). Processing receives (and uses) these values and prompts other values by sending a byte on the serial port (more values). Now Arduino sends other values and Processing requests other data and so on.
-
Firmware. Arduino code that sounds a piezo (piezoelectric transducer) using a photoresistor (which determines the frequency of the tone) and a potentiometer (which determines the duration of the tone).
-
Software. Processing code that draws a radar using a photoresistor (which determines the radar beam) and a potentiometer (which determines the color hue in HSB mode). Use a button to reverse the direction of the radar (clockwise or counterclockwise).