I hooked up a force-sensing resistor to a breadboard and Arduino in analog pin 0. I programmed the Arduino to read the analog input data in bytes, which sends out the raw binary value of the byte in ASCII characters. This form of output looks like mumbo-jumbo gibberish in the microcontroller’s serial monitor, however when I read the data through Processing, I can graph the sensor’s values in a colorful sketch which is a much more useful form of output.

To get Arduino to talk to Processing, I told Processing to access my computer’s serial port that I am using for the microcontroller. I imported the Processing Serial Library, and told Arduino to display a list of the available serial ports in my monitor:

List of serial ports

List of serial ports on my computer

In Processing, I wrote a program that reads the values from the force-sensing resistor as I squeeze its surface, and graphs the incoming values in a sketch. I used a specific method called serialEvent () to read the incoming bytes from the microcontroller. As each byte is sent through the serial buffer, its value is displayed in the changing graph.

First, I created a line graph:

Line graph based on FSR sensor values

FSR sensor values in line graph

Then, I created an ellipse graph:
FSR sensor values in ellipse graph

FSR sensor values in ellipse graph

Also, ellipse graph filled in:
FSR sensor values in ellipse graph (filled)

FSR sensor values in ellipse graph (filled)

Finally, I created a bezier graph:
Bezier graph based on FSR sensor values

Bezier graph based on FSR sensor values

Also, bezier graph filled in:
Bezier graph (filled in) based on FSR sensor values

Bezier graph (filled in) based on FSR sensor values

Here’s my Processing sketch for the bezier graph:

Sensor Graphing Sketch

 This sketch takes raw bytes from the serial port at 9600 baud and graphs them.
 October 2010
 By Suzanne Kirkpatrick

import processing.serial.*;

Serial myPort; //the serial port
int graphXPos = 100; //the horizontal position of the graph

void setup () {
  myPort = new Serial(this,Serial.list()[0],9600);

void draw () {

void serialEvent (Serial myPort) {
  //get the byte
  int inByte = myPort.read();
  //print it
  //set the drawing color
  //draw the line
  bezier(graphXPos,100,graphXPos,inByte, 80,80, 100,100);
  //at the edge of the screen, go back to the beginning
  if(graphXPos >= width) {
    graphXPos = 0;
    //clear the screen
  else {
    //increment the horizontal position for the next reading


No Responses to “Lab – Serial Out Using Arduino”  

  1. No Comments

Leave a Reply