Sunday, 21 August 2011

Running Amok

It's my first blag parst!

If you ever live in fear of your significant other, knowing the moment they step in the door the yelling and the screeching and the jabbing will start and knowing you'll just wind up locked in the broom closet again for a week, living off leeks and whatever insects crawl in through your filth, then read on! What better way to diffuse an angry situation then by playing fight music as soon as they (or anyone) comes in the door. No one can actually fight while fight music is playing! I decided to give it a try.



Step 1
You need a way to play the music. I have an old MP3 player and a spare set of speakers, so this seemed a logical choice. My plan was to tack some flywires to the play button (which conveniently acts as the on and off button too) and thus control the device through a microcontroller. So I pulled the MP3 player apart.


Unfortunately, after lots of probing and prodding, there seemed to be no accessible soldering points for flywires. It also seemed like the folks who made the MP3 player had to do a little bit of post-PCB-design rework. I don't envy the poor souls who had to attach that red wire by hand on so many millions of units.


Plan B
Use the button mechanically. Why not right? Fortunately I have a few servos kicking around, and I spent a bunch of time back in the day making nice Arduino code to use them. After some hacking at the code, and some good old fashioned MacGyvering, the deed was done.


Step 2
Now that the MP3 player can be activated, it's time to figure out the switching mechanism. I used a simple reed relay and magnet. When the magnet is near the switch, it's closed. When it moves farther away, it opens. So I taped the magnet to the door and the relay switch to the door frame with blinding precision.


To connect this switch to the microcontroller, I needed a long wire with two lines in it. My MacGyver senses tingled once more and I turned to my trusty pal Mr. Component Cable.


Just jam some gator clips onto the contacts and you're good to go! Here's what it looked like on the other end, all hooked up.


I used a 1Kohm resistor between Vdd and one terminal of the switch and the microcontroller input, and I connected the other end of the switch to ground. So when the reed is closed (and the door is closed), the microcontroller sees ground, and when it's open the microcontroller sees ˜Vdd.

Step 3
Deploy! Plug it all in and lie in wait.


In Conclusion
I really need to get a job.

Links
http://www.sparkfun.com/products/8642
http://www.sparkfun.com/products/8643
http://www.arduino.cc/en/Tutorial/Button
[Code link coming soon!]

2 comments: