P-Comp: Serial Output

Serial Output Lab

I worked on this week’s lab with Meredith.  First we set everything up as specified in the lab.  No real problems, pretty straight forward as the video below shows.

Then we wanted to visualize the signal from the serial in a more personal, creative way, so I adapted the big orange circle and blue background from an old ICM project and tried to link the pot reading to the diameter of the circle.  Something stopped working though.  We started double checking wires and scanning every line of the code, but we still could not get the Arduino to talk to Processing.  Then we had a “duh” moment nearly an hour later and just ran the Arduino setup program again.  Then it worked.  Still don’t know why Arduino “forgot” how to output to Processing, even though we didn’t do anything.

The circle diameter did move along with the pot, but there was this nasty flicker that really bothered me, which made me not want to mess with the sketch anymore.  In any case, I think we got the hang of Serial Output.

Here is the code we used:

import processing.serial.*;

Serial myPort; // The serial port
float bigOrangeCircleDiameter = 1; //the big orange circle starts out really small
int bigOrangeCircleGrowthRate = 5;

void setup ()
size(800, 800); // window size
myPort = new Serial(this, Serial.list()[0], 9600);

void draw()

void serialEvent(Serial myport)

// get the byte:
int inByte = myPort.read();
// print it:

//Draw the big orange circle that grows and shrinks
fill(247,101,42); //Orange fill
bigOrangeCircleDiameter = map (inByte, 0, 255, 0,800);
background(68,66,211,20); //turn the background blue