masthead

“The Dock,” A real-life Arduino-powered OSX dock

For my final project in Physical Computing, I’m making a real-life Mac OSX dock, with little Sculpey icons that you can use to open and close programs.

First some pictures: the outside, the inside and the icons.

It works by measuring the values of resistors that I glued on to my icons. Each pair of brass washers coming out of the box acts as a switch that can only be turned on by putting an Icon on top of it. Any icon can be placed on any spot in the dock, which completes the circuit. A wire leads to the analog inputs on the Arduino board, which reads the value and then sends out a character over the USB serial port. Each icon has a unique character for it being placed on the dock and for it being removed from the dock.

Reading those serial calls and having them control the applications was harder than I expected. My first plan was to use ASProxy, a program which runs different AppleScripts based on a character received over serial. Sounds perfect, but it didn’t work with how I had coded my handling of the circuit. It seems that to get good results from ASProxy, you have to write the character to the serial port often over many calls to Arduino’s loop() function. In my program, I only write to the serial port once, and I have a hefty delay between loops so that brief connection outages won’t produce odd results (for example, if someone knocks the icon off but then quickly places it back on. Magnets are going to be my next solution to this).

The next solution was to try and have Processing handle calling AppleScript functions. That led me to this Processing hack which doesn’t seem to work anymore. Processing didn’t like having to import that library - but there is a solution to this! Gotta love the Processing forums. You can call AppleScript by using shell scripts, as described here.

I still have a few problems to fix before this works perfectly. It seems that Processing is receiving serial calls even after I have placed and removed an icon. For example, if I place my iChat icon on and take it off, it works fine, but then will continue to open and close iChat. So I need to look into where those calls are coming from (using the extremely useful ZTerm, which has made many things in this process much easier). Also magnets would be a nice touch, so I will figure out a way to have them as well.

Arduino Beer Theft Prevention Device

Ah, Physical Computing and tight deadlines. Nothing gets my creative krausen frothier. Which is why I am now able to present to you this monstrosity of a contraption, the Beer Theft Prevention Deviceā„¢.

It would truly be a travesty if someone at a party were to ask, “hey, which of these beers is mine?” and then pick up YOUR beer by accident. So that everybody knows which beer is yours, I strapped a bunch of electronics to a beer bottle. Problem solved.

To complete the requirements of the assignment, however, I had to make those electronics do something. So here’s how it works: There’s a switch on the side of the bottle. When it is disengaged, nothing happens, and you can drink your beer normally. When the switch is engaged, it turns on an ultrasonic rangefinder that checks the distance of any would-be beer thief’s lips from the mouth of your bottle. If he gets too close, it tells a solenoid to let go of its hitherto magnetically-attracted rod. As the thief tilts the bottle up to take a sip, gravity takes over and the rod falls in their face, hitting them right on the nose.

Crisis averted!!

Bill Cosby Sweater Musical Generator

My next project for Physical Computing was to make something wearable, so I chose a poncho which, when worn over a Bill Cosby-esque sweater, would turn the colors of the sweater into music. It was composed of three parts: The color sensor, an amplifier and the innards of a delay pedal. The color sensor works quite simply, by flashing a red, green or blue LED at a photoresistor and measuring the resistance. That circuit looked like this:

The code just turned each LED on individually and measured the value coming back into the input pin. It could be calibrated to make one tone for each three LEDs, but it sounded more fun just having each flash generate a tone.

I picked up the delay pedal, a DOD DFX91, off of craigslist. The switch was broken, which was fixed after a little soldering. After running the sound through the delay pedal, though, the volume had been lowered considerably. In my travels for an amplifier, I came across the Little Gem, which worked beautifully (after a few missteps with my amateur soldering abilities).

Finally, I picked up a cheap plastic poncho, and with the help of some duct-tape reinforcement, attached everything together. Here’s a picture of me looking quite silly it. I have started to take it apart again for the next project, but I’ll take a sound clip of it in action and upload that soon.

Photoresistor Color Sensor with Arduino

As a part of my next Physical Computing assignment (more on that later), I need to build a little module that will read the color of whatever it is pointed at. I’ve been using this site as a starting point, which is very helpful. What happens is that three LEDs - one red, one green and one blue - light up in sequence and the reflected light is measured by the photoresistor. Those three values can be combined into one RGB color which the computer can display. Pretty nifty!

In the example, they have a integrated circuit powering the cycle of the lights. I took a look at the documentation for the counter circuit we have in the lab and it was totally over my head, so I decided to use the Arduino to take care of the cycling. This limits how many color sensors I can have running in total, but the LEDs are pretty pricey, so it’s probably for the better.

My next steps with the color sensor are to calibrate the LEDs by getting their values against something white and something black. Then I should be able to map the values in the range of 0-255 and have Processing produce a color. I’m having problems with my Wordpress uploads permissions, so I will post pictures later.

TwitShit

My first project for Physical Computing was to find a creative way to turn an LED on and off using Arduino. A while ago, I said that the only way I’ll use Twitter (which I think is beyond pointless) was if I could hook it up to our cat’s litterbox and have it “Tweet” every time the cat takes a poop. An LED would light up to signal “the litterbox is occupied” or start flashing to signal “warning: it may smell awful.” And that’s exactly what I did!

I had first planned to install an ultrasonic sound emitter inside the litterbox to detect if there was something inside. When I went to Jason to look through his box-o-sensors, however, I found the flex sensor which was not only much easier to use than the ultrasonic emitter, but it would be much easier to code for as well. The flex sensor outputs a number which tells me if it is bending one way or another.

p3170089

Once I had wired up the board, I took to writing the code. The Arduino code checks three times a second to get the value of the sensor. If it is bending into the litterbox, it signals the LED to turn on. If it is bending out of the litterbox, it tells the LED to flash for a few minutes. The Processing code is responsible for posting the Twitter updates, which works like this: the Arduino board is able to broadcast information via the USB port back up to the computer, which Processing listens for — this is called a serial event. Depending on what the event parameters are, I can tell which direction the sensor is flexed in and post the appropriate tweet using a nifty library called JTwitter. Here’s a screenshot of the programs running on my laptop (technically, Arduino doesn’t have to be open for it to work, but it looks cool with them both there):

screenshot1

And here is a picture of the installed “device:”

p3170090

If you’re interested, you can follow our beloved cat Reptar on Twitter here.