This is my second ever Picaxe project. Shoot, it's my second ever electronic circuit to design and build myself.
Halfway through this project, while exploring the "tune" command in the Picaxe programming language I came up with an idea for a modification to a puzzle box I had. At first I just wanted to make a circuit that played different songs using the monophonic ringtone playing feature of the Picaxe. When I chose the puzzle box as my project box I decided to up the ante and make it a game.
When the puzzle box is tilted or jostled the box will begin playing the "Mission Impossible" theme song at normal speed. It will repeat four times increasing in speed with each iteration. After the last time the box will play a descending white noise sound (like "pshhhhhhhheeeeeeeeeeeeeeeeeeeewwwwwwwwwbbbooooooooaaaaaaahgurgglegurglegurgle" GAME OVER!) These sounds will repeat until someone successfully opens the box and "defuses" the game.
If there's any interest, I'll make a video.
Updated design, pictures and program coming soon.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts & Tools
2 LED's (optional)
Perfboard (I used one Radio Shack had that is made for 20 pin IC's but... your choice)
Resistors (see schematic)
Capacitor (22 uf)
Speaker (smaller the better)
Solid core wire
SPST Switch (this will be your "defuse" switch so feel free to get creative)
Trigger switch (tilt switch, reed switch, secret magnet switch,?? I'm still working on this part)
9v Battery with a battery cap
Box to put the stuff in. ($5.99 at Amazon)
Step 2: Design
OK, I'll be honest. I didn't plan my circuit well. I'm new at this. I spent a lot of time staring at the picaxe manuals and drawing and erasing with a pencil. I'm sure most of you have fancy open-source software that makes all this a breeze, but I haven't found any that I can figure out how to use yet. So stop judging me.
The point is, you need to design your circuit. I don't believe you should ever just copy someone else's schematic without at least trying to understand how it works for yourself. What's the point? Why not just buy stuff pre-made? Rant over.
Since I was using an oddly designed perfboard I really had to think about where things went. Next time I think I'll use a regular old grid even if it means a few extra connections.
So, If you need a little more direction I'll talk you through the major points of the circuit. 9V+ comes in directly from the battery and connects to the 5v regulator. The regulator has three pins. Input, ground, and output. Connect +9v to the input and the output will provide +5v. Don't get confused and connect anything else to the 9v+.
I put a couple of small capacitors across the regulated supply just because the picaxe literature warns you that this is important. I'm not so sure, but why not? Found these unnecessary so I removed them for space.
Now to the chip itself. Counter clockwise. (Note: ignore these pin numbers when doing your programming, refer to the manual in the help files!)
Pin 1= +5v
Pin 2= Serial input for programming. If you are programming this on your breadboard you still need the resistors on there to keep the chip happy.
Pin 3= LED output. Just add a resistor in series with the LED and you're good. 330 ohms is the standard. I think I used something slightly larger I had around.
Pin 4= Push button switch. I added this early on, but it really isn't necessary for the program I ended up with. I just left it on for an added feature. And I hate to waste perfectly good pins. Wire it so that when the switch is closed (powered!) there is a 1k resistor between +5v and the pin AND so that when the switch is open there is a 10k resistor between the 1k and 0V(ground). I think the picaxe manual explains it better.
Pin5= Capacitor and Speaker in series. The capacitor filters out DC noise or something they tell me. The result is a louder speaker. Mine was plenty loud without any amplification. If yours is too loud add a resistor in the series or a trim pot to adjust the volume.
Pin6= Tilt switch. Wire it the same way as pin 4 except use the tilt switch.
Pin7=DUAL USE... Isn't that sweet that picaxe lets you use this pin two ways?
The first use is for programming. This is the serial output. It is important if you want to program the chip on the board. You just need a way to connect your programming wire to it. I use alligator lead wires.
The second us is for an LED output just like pin 3. Again, you can leave out the LED's. They just blink. What am I saying? You MUST put the LED's in because every project needs blinky lights.
Pin8= 0V. Ground this pin.
Clear as mud? Simply speaking this circuit uses two pins to output to LEDs,one pin to output to speaker, and two pins to receive input from switches.
Now all that's left is the "defuse" mechanism. Once the player figures out how to open the box there needs to be a way for them to stop the program. I've decided the best way to do this is to reset the whole program by cutting the power. I'll add some kind of switch to the battery wire. Or maybe I'll just cut the wire and twist the ends together by hand. That way the way to "diffuse" the device is to actually pull the wires apart. We'll see.
UPDATE: I've added the schematic. No guarantee this is perfect as I have just started learning to use Eagle, and I have no idea about standards or best practices for schematic design. Helpful critique is welcome.
Step 3: Build the Circuit.
I decided to keep my circuit independent of the box it was placed in. By that I mean I did not connect anything directly to the box. This will allow me to take it out and show off my skills to any nerd interested enough.
I can't think of any tips to help you here. Just do one connection at a time, be careful and try to catch mistakes as you go. I only had to remove and replace one resistor, but it was a major hassle.
Feel free to ask questions.
Step 4: Program the Chip
With my setup I found it easy to attach alligator clips to the appropriate spots so I could program the chip directly on the circuit. You may find it necessary to build a temporary circuit on your breadboard and program the chip there.
I'll add some pictures of how I use the programming cable directly on the circuit later.
If you wired things the way I did please note that the LED attached to Serial Out will blink during program download.
If you don't know how to program your picaxe read your manual or ask here. Maybe someone will take pity on you. It is a multi-step process, but once you do it you'll see its pretty easy.
I suggest you write your own program and chose your own songs, but here's mine. If you are looking for other songs, I noticed that there are some included archived in the program folders you download with the program editor.
'Mission Impossible by Bennett Sanderson
'April 1, 2012
main: 'the main part of the program simply waits for input
if pin1=1 then mission 'pin1 is the tilt switch.
if pin3=1 then hail 'pin3 is the momentary
for b0=4 to 1 step -1 'Play the song four times faster each time
tune 3, b0,($4C,$42,$43,$42,$43,$42,$43,$42,$43,$42,$42,$43,$44,$45,$46,$47,$47,$4C,$47,$4C,$4A,$4C,$40,$4C,$47,$4C,$47,$4C,$45,$4C,$46,$4C,$47,$4C,$47,$4C,$4A,$4C,$40,$4C,$47,$4C,$47,$4C,$45,$4C,$46,$4C,$4A,$47,$C2,$4C,$4A,$47,$C1,$4C,$4A,$47,$C0,$4C,$6A,$40)
for b2=250 to 150 step -1 'Explosions sound
goto mission 'Infinite Loop! If you'd rather the program start over at this point change this line to "goto main"
hail: 'This is the fight song for my dad's college
tune 3, 5,($E0,$27,$24,$C0,$6B,$69,$67,$24,$67,$24,$27,$E5,$25,$64,$25,$22,$24,$65,$E7,$26,$67,$29,$26,$27,$69,$6B,$67,$65,$62,$E0,$27,$24,$C0,$6B,$69,$67,$24,$67,$24,$27,$E9,$29,$68,$29,$2B,$00,$27,$E4,$29,$6A,$2B,$27,$C0)
Step 5: Stick It All in the Box
If you have a tiny box like I do you may have to bend some components to get them inside. Take care not to break of your leads. That would make you cry. It helps if you don't solder tall items tightly to the board. This applies mainly to the capacitors and the voltage regulator.
If the 9v battery is too big, the same circuit could be run off any batteries supplying 4.5 volts or more. I chose the 9v because it only requires one battery with no case and will probably last longer than smaller batteries. I have heard of people breaking open 9v's to use the skinny cells inside (I think they are 1.5v individually, 3 of them would work). I don't know if that will work or if it is safe. You're on your own there.
Step 6: Play!
Go drive your friends crazy. Word of caution. For some reason many people think opening a "puzzle box" is not about outsmarting the box. They think that somehow it is okay to simply pry the thing open. Remind these people that if you wanted to test their strength you would have given them an iron bar to bend or a water bottle to explode with their breath. Let them know up front that the puzzle can be solved without breaking anything or forcing anything.
You could use this same circuit in other ways. Instead of putting it in a puzzle box you could put it in a clear box (ipod packaging?) with a lot of extra wires. Challenge your friends to "cut the right wire" to stop the device before time is up. Maybe add a countdown clock display?
Anyway, sky's the limit. I hope this helps someone make something cool and improve their skills while doing something creative.