Serial Communication

Lab 1: Serial to Processing

Here’s we’re starting with the basics of reading sensor data through a serial connection. USB in this case. Then we write a Processing sketch that reads from the serial port and outputs a graph of the sensor reading. The graph is an arbitrary visualization. It could be any type of visual that you want, as you’ll see in the second lab.

I used one of the Arduino kit potentiometers for my first set up.

Photo Sep 30, 7 02 58 AM

It worked well enough. But something strange was happening: every once in a while I would get nothing as a reading. A sting of random characters and then nothing. Sometimes I could wiggle the sensor and the readings would return, sometimes not. I think this might be on account of these kit sensors being kind of crap.

Next I decided to try out a new FSR (Force Sensing Resistor). That worked and there were no strange readings. Also, what’s nice about the FSR is that it creates really smooth curves. The growth and falloff from each high pressure input plots a nice slope, with no jumpiness.

Lab 2: Multisensor Serial Communication

In this lab we’re setting up several input devices at once and creating a parse-able string. (Sidenote: if someone is reading this and any terminology is incorrect, please let me know so I don’t look like an ignorant asshole. Thanks so much.) All that means is that we’re reading several inputs at one and telling Arduino and Processing how to break up the string of values in order to get individual readings from each sensor.

I used an FSR, a kit pot, and a toggle switch .

Photo Sep 30, 8 02 29 AMI had no trouble getting this up and running on Arduino and getting the Processing sketch to run, but I couldn’t get the sensor to talk to Processing.  It was perplexing. Perplexing and not vexing because some aspects of the whole system were working. Arduino was giving me beautiful reading after beautiful reading.

FSR: 123, Pot: 990, Switch: 0
FSR: 130 Pot: 870, Switch: 0
FSR: 150, Pot: 720, Switch: 0
FSR: 266, Pot: 103, Switch: 1

And so on…but Processing was giving me nothing. Occasionally an “Error, disabling serialEvent() for [the port name]      null,” but I figured that was just a connection problem. That wasn’t the problem becuase Arduino was still showing readings. It took some time before that I realized that the strings weren’t supposed to include the sensor names, “FSR,” “Pot,” “Switch.” I had added them in for clarity. But they were screwing with the string being properly parsed. I removed those extra parts of the string and I was up and running.


  • As far as the code goes, I understand in theory what’s going on and I can point to which block of code does what, but I need a little explanation of some of the syntax in each of the programs.
  • Why did I sometimes get “Error, disabling serialEvent() for [the port name]      null” and sometimes not?
  • In the second lab, why aren’t we using different variables for each sensor?
  • In the Handshake method, the first “hello” is always misspelled. Why is that?
  • What am I going to have for breakfast now that this lab is done

P-Comp Lab: Servos & Speakers

Self Servo

Servos are small motors with a 180º angle of movement. They can be precisely controlled. Or so I’m told.

My servo circuit worked. Sort of. If I turned to control too fast or as it reached the end of its range of movement it started to wobble like a fat man on a kayak.

I’m not exactly sure why this happened. Although I can poisit the potentiometer was the culprit from the Serial communication  feedback I was getting. At the high end of the potentiometer’s range (which was mapped to the high end of the servo’s range of movement) the numbers were jumping back and forth in a seemingly random pattern.

I’ll need to try this same set up with a more robust potentiometer and see what happens.

 Bringing the Noise

My little baby Arduino starter kit didn’t come with a speaker. So I went to the venerable Junk Shelf to see what I could find. (Spoiler alert: I found treasure.)  Photo Sep 23, 2 40 29 PM

I can’t tell you exactly where on the Junk Shelf I found this windfall. That would break the promise I made to the wizard who showed me the way. I can tell you what I found: a wireless phone handset.

Photo Sep 23, 2 40 57 PM

And tucked in the murky plastic shallows just beneath the outer layer I discovered a small speaker with clearly marked Power and Ground wires. Joy of joys! So I ripped it out, leaving a plastic carcass behind for the hands of fate/other ITPers to decide it’s ultimate destiny.

Photo Sep 23, 2 41 18 PM

The lab itself was fairly straight forward. I hooked up a circuit and followed the instructions to write a program that told the speaker to emit a series of short tones.

Photo Sep 20, 11 52 35 PM Next I implemented two photodetectors as “controls.” After a little tweaking and much flailing I did find that using only one of the photodetectors gave a more consistent sound from the speaker.

Photo Sep 21, 12 01 21 AM
what a shitty picture

At that point I also realized it was past 12:30am and whatever was emanating from my apartment must have sounded like I was trying to make love to an am radio. So that’s where I ended this lab.