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.
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 .
I 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