So, this was the most interesting thing we did in this lab – letting Arduino and Processing work together in perfect harmony.

But it all started when we…
CONNECTED A POTENTIOMETER
We attached the potentiometer’s outer red and black wires to power and ground, and connected the middle wire from the potentiometer to the Analog input pin 0 on your Arduino board.

SENDING SERIAL OUTPUT
Used the following Arduino program to send serial output of the values as bytes out to the computer:
int analogPin = 0;
int analogValue = 0;void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
analogValue = analogValue / 4;
Serial.print(analogValue, BYTE);
// pause for 10 milliseconds:
delay(10);
}
CHECKED SERIAL OUTPUT
We opened the Arduino serial monitor and using the default settings of parsing at 9600 baud, we played with the potentiometer to see the output (or scrolling) of ASCII values.
Turning the potentiometer at different speeds affected the output (numerals, versus capital and lowercase letters). Click here to see it in action.
VERIFYING SERIAL PORT
We loaded a Sensor Graphing Sketch program to Processing. But first, before putting it into action, we verified the correct serial port.

MAKING A GRAPH
After verifying, we played the graphing program in Processing. This program basically demonstrated how serial output can be used to drive communication between different software components (in this case Arduino and Processing). And here’s the result:

