This Instructable shows you how to build a clap activated LED strip. The whole project is based on the Adafruit's Secret Knock Activated Drawer Lock, where the user can record a secret knock pattern which will open the lock inside the drawer. I thought that I could use this to siwtch an LED strip on and off with a handclap pattern. So let's begin!
Step 1: Components
I used the following components to build the circuit:
- 1x Adafruit Trinket 5V
- 1 x Simple white LED strip (1,5 m long)
- 1 x LED strip snap connector
- 1 x Arduino compatible sound detection module (Microphone)
- 1 x Green LED
- 1 x 240 Ω resistor
- 1 x 10 kΩ resistor
- 1 x STP16NF06 transistor
- 1 x Pushputton
- 1 x 12 VDC power supply
- 2 x Panel mount DC barrel jack - Female (size depends on the power supply's jack size)
- 1 x DC barrel jack - Male
- 1 x Breadboard (for prototyping)
- 1 x Solderable protoboard (for the final circuit)
- two core wire for the LED strip
- single core wire for the circuit
- female headers (if you don't want to solder the microphone and the trinket directly onto the protoboard)
- Soldering equipment
For the casing I used:
- 1 x Aluminum profile for LED strip (2m long, with end caps and opal cover)
- 1 x Equipment case (88x63x48 mm)
- Hot glue
Step 2: Code
For the code I modified the one presented on the Adafruit site. To upload and run the code on the Trinket you will need a mini usb cable.
Note: Before uploading a code to the trinket please follow these steps.
The code can be found below.
Step 3: Wiring
At first you should put together the whole circuit on a breadboard to check if everything works fine and to experiment a bit with the sensitivity of the microphone.
Note: On the wiring picture above a different kind of microphone is shown, because the Fritzing part library hasn't got a similar one we use for this project. The most important thing to remember is to use the digital output of the microphone's breakout.
If the sound threshold is crossed by your clap a built in LED will light up and you will get a signal on the digital output. This is what we need.To set the correct threshold, turn the screw until the previously mentioned LED will light up, then turn the screw backward until the built in LED is off. Probably some fine tuning will be needed, but always use the screw on the breakout to do that.
The green LED is some kind of status indicator. It should light up if a clap is detected. If a clap pattern is not valid then it should blink very fast for a second. When the threshold level is not set correctly and the microhphone always "hears" something, the LED will light constantly. In this case try to lower the sensitivity of the mic with the screw on the breakout.
And remember to connect everything to a common ground!
Step 4: Putting together the LED strip
The LED strip will be placed in an aluminum profile, which will give an elegant look for your device. At first cut the double core wire to the length you want, then pull on one of the end caps. Then solder the wires to the snap connector. After this is done connect the LED strip to the snap connector. Then cut the aluminum profile to lenght, but remember to provide some place for the snap connector because we want to hide it under the opal cover. After this stick the LED strip in the aluminum profile. Attach the other and cap and the opal cover. We are done with one end of the core wire, now comes the other one. Solder a proper male barrel jack to the end.
We are done with the LED strip part of the device. Let's move on to the casing!
Step 5: Putting together the casing
The very first thing you want to do before you solder the things together is to place the conponents in right position. Check wether they fit in the box of your choise or not. Remember that the microphone's sensor should be placed on one of the sides or on the top of the box.
Cut holes with a drill for the two female barrel jack connectors, the pushbutton, the status indicator LED and the microphone.
Now you can solder the things together! I used wires which is not so elegant as a PCB board but it will do. Use connectors or headers wherever you need. The status indicator LED can be fixed with a bit of hot glue.
Pay attention to the polarity of the connections (which wire is + and - ) !!!
Step 6: Final words
After you prepared the LED strip and the box it's time to connect them. Plug the strip's barrel jack into the input of the box and plug in the 12VDC power supply into the input of the box. To know which plug is which I printed some stickers for the box.
Be aware that you might have to correct the threshold of the microphone, because the soldering can make some change in the resistance of this sensitive part.
I hope you can make this device without any trouble, if not feel free to ask.