Serial Communication Lab – Hudson

So I finally got to work on the serial communication lab after overcoming the many error messages I was getting (see post below for the solution). The first step was working with some buttons attached to Arduino in order to get an output in Processing.  This wasn’t that dissimilar from the work my group had done for Project 2. See pictures in the YouTube video below.

After that I did the graphing of a sensor output. Again, this wasn’t that different from my work with Project 2; I just had a lot more data! I played around with the colour and tried to apply a smoothing function. The smoothing function didn’t smooth as much as I’d have hoped, perhaps I needed to smooth across more than 2 data read cycles? Nevertheless, moving on! Lots of things to learn…

Recolor graph.

The dimmer was fun. Nick had done the same thing in class so It was nice to see exactly how it was achieved. Swapping out the LED for a servo was a simple matter of calling up the servo example in Arduino and copying and pasting over a few key functions and replacing/removing some values relating to the LED. You can see it in action in the YouTube video below.

I wasn’t really sure what to make of the data types section (4). I wired everything up and got it working. I think I need to go back and compare my work on section 5 with the second section of section 4. This will make the difrences more clear. Nevertheless, I had a clear enough understanding of what was going on to proceed to section 5 and start making edits.

Section 4, part 2 in action.

For exercise 5, I started by mapping the variables received by Processing to allow the on screen element to reach the extents of the screen. Before, when controlling, I was limited to only about a quarter of the screen. I then changed the button’s behaviour through code to allow it to be toggled off and on rather than having to hold it down to keep the onscreen character active. This made more sense to be as now I could operate the x-axis of the white circle with one hand and the y-axis with the other. I then added a gaming element to the code. I did so because moving around a white circle on screen is cool but moving that same circle around a screen to eliminate other red circles is amazing! I used to ‘dist’ function and some randomly generated variables to do this. It wasn’t quite right though. So, lastly, I inverted the mapping of the X position of the white circle. This made the experience play more like traditional side scroller games which begin in the lower left hand corner (Mario, Contra, Sonic) rather than the upper right.

Project 3 – ‘1 Mile’ group

Yuxi Wang, Maziar Ghaderi, and Hudson Pridham have teamed up to take on evil and bring you the ‘1 Mile’ project. ‘1 Mile’ intends to connect people and break free from loneliness by letting strangers walk a mile in each other’s shoes.

Processing & Arduino serial communication problems

I’ve been hearing from a few people in our class having problems getting the serial communication lab working. I experience these errors myself which was concerning seeing as how I used serial communication for project 2. Anyway, I tracked the error down to the version of Processing I was using. Downgrading fixed the issue. I’d recommend Pre-release version 2.0b4. You can find it here:

Also, make sure you’re listening on the correct port. Insert the following code into your ‘void setup()’:


This will give you a printout of the available ports; change the ‘0’ following ‘Serial.list()’ to the one your arduino is on.

See you tomorrow. Until then, keep on keeping on.

More Project 3 Links

In Project 3 we will be looking at how to use Wireless protocols & Data Services to extend your space beyond its physical walls.  Below are a few of the potential setups

Data Links



A Record Player That Turns Felt-Tip Doodles Into Electronic Music

Check this out.  I think it’s pretty cool and seems simple enough.  Do you think they’re using something like Processing?  Would you need anything more?

This is the link to the full article:

Basic Threshold Switch from a Mic

The Electret speaker breakout board from Sparkfun has been super popular in class so far.

The thing is that when you finally get it wired up, it outputs what appear to be random number pulses. In waves. These are the amplitude wave of the sounds near the microphone, not an error. They can themselves be used for many things, but will not tell you if, for example, someone is talking TO the critter, just the background levels. Terrible! We need a threshold to tell us when someone’s surpassed the normal background volume instead.

Much like “face recognition,” “hearing” speech is tough. This is simple. This creates a threshold switch from a microphone. It will tell you when the sound levels nearby change to a wider range than “normal.” It requires some calibration, and some simple math. If you are outputting to a nearby speaker, it may not work very well; it will hear the speaker, as well as yourself. Better math would fix that issue. This is a simpler switch than that.

electret breakout wiring
To wire it, hook 5v to a 10k pulldown resistor, ground to ground, and information to A1* as in the diagram. The datasheet says the thing needs 1.5v in, and most sources say a 5k will do you, but a 5k gives you a big fat wave with numbers between 200 and 400 – it looks super random. The 10K will compress your business like no nevermind.

*NB: I prefer A1 to A0 because A0 sometimes acts weird, and code occasionally interprets a “0” as a null value. This is important with analog inputs.

Once hooked up, here is your code:


Electret Mic Threshold Reader
Alex Leitch

Oct 31 2012

Appropriate for All Ages, 2006, uses a much-simplified version of this circuit.
That one ran on a similar mic circuit, picked up for $3 in a spare halloween “spooky robots” pile.
This is better because you can calibrate it, that was better because you didn’t have to. Also, it cost $3, not $30.


const int pinSpeaker = 3;

int valMic;
int valMicRange;
int valMicLast;

int iHearYou; //set threshold for “being talked to”

void setup() {

void loop() {

valMic = analogRead(pinMic); // every loop read the mic

valMicRange = abs(valMic – valMicLast);
// take an absolute value of current and last value of amplitude wave for threshold

// Find out what the absolute value of difference is – this will make a pretty visualizer out of your thresholds

if (valMicRange > iHearYou) { //do something if threshold is passed

else { // if not being talked to, what to do?

valMicLast=valMic; // hang onto that mic reading


Here is where the exhortation to do Amazing Things with this information comes in! But no. I am not going to lie to you: working with sound is tough and the sort of thing [redacted judgemental comment] (hi there, GearSlutz) work with. Sound is a wave, which is to say a four-dimensional transform, waves are a challenge if what you really want are robots. Sound becomes useful as a switch when, using thresholds maybe, you can transform it from a wave to a point, or at least a baseline, which is what this circuit does. Audio obsession knows no upward bounds. That message board is maybe the best review board for people who are really into analog inputs, though, and I think you may find something of use there.

Appropos of nothing, The Simpsons. Happy Hallowe’en.

Full Screen Processing Window

I came across a Processing library that may be valuable to a number of teams. It allows stretching of Processing sketch to full screen.

This is great because the Kinect skeleton server doesn’t seem to play well with large Sketch windows (larger than 640×480). Stretching is the only way to go!

more files

files for thursday night