Note: this is my first post documenting a project completed as part of my work at NYU ITP. Throughout my time in the program, I will use this blog to write-up my work for class as well as other observations and ideas. Hopefully, this will not make too alienating a change in subject matter from what I’ve posted here in the past and will mean many more posts. Enjoy!
The first assignment for Intro to Physical computing was to use the Arduino to detect the closing of a switch and to turn on an LED when the switch was closed. I decided to put the switch and LEDs to work doing something useful: photographing the moment of collision between two MatchBox cars.
Here was my plan: connect each car to the circuit as if they were two ends of a switch. Then, when the cars touch, since they are metal, they will complete the circuit. The Arduino could detect that contact using digitalRead and flash a bank of LEDs so as to take a picture of exactly the moment of impact using a camera with a long-open shutter. The concept:
I started off by buying some MatchBox cars at K-Mart and experimenting with them until I found two that had metal (or metal painted) undercarriages that were conductive enough to set off the multi-meter. Then, I bought some conductive thread and figured out how to attach it to the cars by tying it around and between their back wheels so that it would be pressed against their metallic underbellies, allowing them to be incorporated into the circuit.
I wired them up to one of the Arduino digital pins, to power, and to ground through a 100k ohm resistor (I didn’t have a 10k and I figured 100k would do the trick as well). I programmed the Arduino to digitalRead the pin and to blink the built-in LED on pin 13 when it saw a signal. Here’s a video of an early version of this setup in action (notice, I’ve only got one of the cars actually tied to the conductive thread; the other one is just leaning against a free floating lead):
Once I had assured myself that the setup was working, I tied in the other car (video here) and then moved on to testing out the lights.
I figured I would need multiple super-bright LEDs in order to get sufficient illumination to take a visible picture. Rather than messing around with wiring them in series with a stronger power source, I just used five of the Arduino’s digital pins and then wrote a little subroutine to light them all at once by looping through an array of pins. Here’s a very grainy video of them in action:
Now, I was ready to combine the two pieces into the full concept. I attached the LEDs and car-switch to the same breadboard and combined the two halves of the program. Here were the results:
Pretty encouraging! The timing on the LEDs obviously would need some tweaking. Having them stay lit for 500ms would produce streaky images as the cars bounced off of each other.
I also needed some kind of incline to accelerate the cars towards each other. Luckily, I found a cardboard box that (when folded and cut a bit) formed two facing inclined planes:
Now, I was ready to take some pictures. I found an empty classroom, setup the electronics and the inclined planes, mounted my camera on a tripod, turned off the lights, set the camera for a three second exposure, pulled the cars up the planes, and let ‘em rip. And lo and behold…pictures of cars crashing!
As you can see from some of these pictures, at first I was having a problem with multiple exposures. The cars would collide triggering the LEDs and then would either stay touching or overlap each other’s trails of conductive thread, triggering them again and again. I also had issues with the cars setting off the LEDs by merely passing close by each other and trailing their thread together:
Or similarly when I was trying to move the cars into position in the first place, hence capturing my hands:
To eliminate accidental double firings, I adjusted my code to introduce a delay after any given flash. I also shortened the blink time to try to reduce motion blur. Those changes mostly did the trick and I produced some cleaner images after that point:
Here’s some shaky, out-of-focus iPhone video to give you a sense of how briefly the light was actually lit. (n.b., in this clip, the impact is happening at about half its real rate because I only had enough hands free to drop one of the cars down the incline while shooting the video):
And here’s the final code I came up with for the Arduino after my last set of tweaks: