This project was something I did before I really understood how to use micro controllers & their shields. I wanted to build a Halloween prop that is usually referred to as "Trash can trauma" but I had my own concept in mind. Instead of using a trash can I wanted to make a jack in the box display.The project has gone through several updates but what I plan on focusing on is how I added sound to it. It works so reliably I Haven't bothered to update the audio portion of the project.
Since this is a project that I put together some time ago There really isn't a step by step process outlined here but the sound portion is something that is really simple & can be used on many different projects. I will try to explain enough that just about anyone could build the same project if they wanted to.
Step 1: A Word of Caution
I would just like to make anyone, that doesn't already know this,aware that air pressure can be dangerous. If you have any doubts about your project, err on the cautious side. When testing, use very little pressure & when setting up use only the amount of pressure needed. A broken hose can swing like a whip and a cylinder can exert enough force to break bones & knock out teeth. DO NOT TAKE THIS FOR GRANTED!!
Step 2: Parts List
There are two way to build this this will be a parts list for both. The parts with "simple" next to them will be for the simpler version and the parts with "advanced" will be the micro controller version. The parts with neither "advanced" or "simple" indicated are the basic parts needed for both versions.
-pneumatic solenoid valve & fittings
-plastic tubing (ice maker water supply tubing)
-(2) 1/8" headphone plugs
-1/8" headphone jack
-1/8" to 1/8" headphone cable (male plug on both ends)
-appliance switch (this is explained in the next step)
-two mp3 players (this is explained in detail later)
-inexpensive computer speakers
-wall wort the same voltage as your solenoid on the valve
-porch light motion sensor (simple)
-(2) screw in sockets (simple)
-lamp cord with plug at the end
-LED Christmas lights
-Arduino micro controller (advanced)
-CdS light sensitive resistor (advanced)
-LED lights (advanced)
-laser pointer (advanced)
Step 3: The Appliance Switch & Mp3 Players
The heart of the audio portion of the project is this switch. To explain this I'll put it in terms that anyone can relate to, your clothes dryer. When you open you clothes dryer door, the dryer goes off & the light comes on & when you close the door the light goes out & the dryer will operate again. It is this configuration that makes the audio switch from one sound to the other in a very simple way. There are 4 contacts on the back of the switch, 2 for what would be the light & 2 for what would be the dryer.
There are two sounds for this project, a dormant or background sound, and an attention getting sound. For the background sound we will wire two wires up to the two contacts that allow electricity to flow when the switch is held closed. The other two contacts will be used for the attention getting sound.
One very important detail is you need mp3 players that will play a song repeatedly. I think most mp3 players are capable of this. I used IPods, because It's what I had available & only needed it for a short time. Really all that I did was break connection from the output of the mp3 player with the switch. When the switch is closed the connection for the sound output from one mp3 player is closed & you hear that sound while the connection for the other mp3 is broken. When the switch is opened, the opposite happens & you hear the audio from the other mp3 player.
What is happening if you look at the diagram is that we either have one or the other plug making a complete circuit. So that when the switch is open you hear the sound from one mp3 player & when the switch is closed you hear the sound from the other mp3 player.
Step 4: Building the Box
I built just a simple box out of 3/4" plywood & 2X4's. The dimensions will depend on how big your prop is, whether it's a head or something else, and how long of a throw you air cylinder has. If the throw on you cylinder is short, it's possible to extend the jumping distance of your prop by using leverage. My cylinders throw was only 8" inches but I wanted my prop to have a little longer travel distance.
When building you box keep in mind the amount of force it will need to endure and the wear & tear it will be subjected to. A cylinder pounding on the lid all night long will rattle a flimsy box to pieces in no time. Reinforce the corners with 2X4's & use long enough screws to hold it all together for years to come. I mounted a metal plate to the inside of the lid to absorb the shock of the impact of the cylinder end. I also used denser wood on the mechanism that holds the head, some common building materials aren't really meant for constant shock, a pine board in this application would probably fail at some point.
The lid is mounted with door hinges also for durability. The lever mechanism that the head is mounted to also utilizes a door hinge. The head prop is mounted on threaded plumbers pipe, the prop doesn't actually come in contact with the lid of the box, it's the top of the pipe that does. With this design a styrofoam wig block can be used, there is very little wear & tear on the actual prop. The opening to my box is "U" shaped rather than a round hole, since mine pivots, it ejects on a radius & need additional clearance in the front.
One thing that needs to be considered is where you'll position the switch. You'll want the switch close enough to the hinge that the weight of the door is enough to hold the switch closed but not so close that your prop's door has to be completely open to activate your surprise audio sound.
Step 5: Solenoid Activation (easy Version)
The solenoid valve used on my project is a 5 port 9 volt solenoid valve manufactured by Festo. Any decent valve will work, a simple 2 port valve can be used, more ports just mean more options & potential for more control. The Solenoid part of the valve can be any voltage but staying with lower voltages is safer. 12-24 volt solenoids are pretty easy to find on auction sites, you'll also need a wall wort of the same voltage as the solenoid. Cut the end off wall wort cord & wire this directly to the two wires for the solenoid. You'll need to test it to confirm correct positive & negative connections. There will not be a switch in this configuration because the motion sensor will act as our switch.
I wired up the porch light motion sensor to the lamp cord. You should be able to insert a bulb and plug this into a wall socket & confirm that it works. Remember to set light to test because the motion sensor in it's normal mode will only work in the dark. Once you've confirmed that you've wired it properly & it works & you've properly sealed the electrical connections, remove the bulb(s) & replace them with the screw in sockets. We will plug our wall wort into one of these & the Christmas light into the other. When the motion sensor is activated it will provide power to the solenoid, activate the cylinder & power up the Christmas lights. Once the motion sensor times out, the power is shut off, the cylinder is retracted & the lights go off. The reason for using LED Christmas lights is for safety, incandescent lights will get hot, and in an enclosed space like this box it could be a fire hazard.
Step 6: Solenoid Activation (advanced)
After being slightly dis-appointed at my inability to control the sensitivity of the motion sensor, I decided I wanted to alter my project so that I could have more control over activation time. The upgraded version uses a fairly simple Arduino sketch, some mosfet circuits, a CdS resistor, and a laser pointer.
I wanted to be able to have lots of control options. I mounted the CdS in a toy kaleidoscope so that it would be a little larger target to hit with the laser pointer and easier to hit from a distance. The box also move a little when it animates so a larger target helps compensate for this. The sketch also enables me to set the sensitivity depending on the intensity of light. I created some light banks from UV LED's & painted my prop with fluorescent paint. The light banks are also powered by a mosfet circuit because the power demands are greater that the 5 volts an Arduino pin delivers.
I used a Arduino sketch found on Instructables for The Arduino laser tripwire https://www.instructables.com/id/Arduino-Laser-Tripwire/ & modified it for my components.Adding a output for the mosfet for the solenoid & an output for the mosfet for the lights.
I regret that I wasn't equipped to get a better video, but at least you can get the general idea with this one.