Update #5: Getting physical

11:01 PM in General by Inez Ang

Getting Arduino to work in Processing is simple enough with a step-by-step guide here.

Arduino + PIR sensor
To begin working with our Sparkfun PIR sensor, we used a great sensor report by an ITP student. Based on some forum threads, analog values could be used to measure distance so we tried extensively to find patterns in the values, making data logs in text files along the way. We gave up in the end because the values were horribly inconsistent.

Since the PIR sensor is constantly streaming information and changes quite quickly, tying our state machine directly to it was making a real mess of the interface with bubbles going off and on all the time and sound terribly disrupting. Thanks to Jeremy Blum, we understood the concept of implementing interrupts and found a wonderful Processing code example on how to do software debouncing to stabilise the reading. *We also love the fact that the code was written for a tweeting cat mat :) *

This debouncing technique was so useful that we implemented the same logic to fine tune our gesture recognition algorithm.

Arduino + Relay Shield
Although we could have built our own relay circuit to control the air pump, neither of us had worked with voltage higher than 9V and honestly, the symbols on the schematics were a little too much to handle at this point. Choosing a relay shield required a bit of research into how much electrical load we needed (220V – 240V) and how much the relay could carry. We settled for the SeeedStudio shield due to availability and the fact that it switches 120V – 250V.
In theory, it’s quite simple. The air pump would be plugged into the wall socket as usual while the negative wire would feed into the relay. This relay is a Single-Pole-Double-Throw (SPDT, thanks Make Electronics!) so you can connect it one end to COM (common terminal) and the other to either NO (normally open) or NC (normally closed). According to the data sheet, the only difference is whether output for on is 0 or 1. The rest is up to the code to tell the relay to connect or disconnect the power to switch the pump on/off.

Click to play video

In our haste, we cut both cables when we should have only done one so it was out with the soldering iron, heat shrink tubing and gaffer tape to be doubly sure.  It was an ecstatic moment when the bubbles came on but it soon turned into a ???? moment when we realised there were no pins left if we attached the shield. A lot more Googling later, the answer was to breakout the shield onto a breadboard to free up some pins.

The submersible LED was chosen due to its low power consumption (6V, 30mA). To save $35 buying a transformer for it, we decided to take a calculated risk – snip off the original power pin, expose the leads and stick it into the Arduino. Fortunately for us, it worked with a 100Ω resistor to protect it. The resistor value was calculated using the formula R = V/I.