This instructable will go through how to make an interactive, multi-function mood light. The core of this project is the BlinkM I2C RGB LED. As I was browsing the web one day, the BlinkM caught my attention, and I just thought that was way too cool to pass of. So, a couple of months later, I decided I'd make some sort of mood light using it. And here it is!
Step 1: What You'll Need
- The light source:
- The controller:
- LM741 Op-Amp
- Electret Microhone (3-lead)
- 2.2k resistor
- 100k resisor
- 200k resistor
- 0.47uf electrolytic capacitor
- 0.047uf ceramic capacitor
- 2x 10k resistors
For the 'tap' sensor, you will only need:
- Piezo element (you can salvage this from certain electronic toys, telephones, and many other electronic devices that beep, or you can get it from mouser, radioshack, etc.).
- 1M resistor
...And for the light sensor you'll need:
- CdS cell (LDR), preferably a very large one (more resolution).
- 10K resistor
- 3-pin header & crimped connector wires (optional)
Alternatively, you could use a homebrew development board to support the ATmega168 micro, and use a DIP-style ATmega168 (the long one with the larger leads). I'm not sure how well that would fit but it is certainly worth a try. If you don't own/have the money for a breadboard, you can solder down a regular ATmega168 to a PCB and add the regulator, programming connections, etc.
Step 2: Prep the 'touch Light'
First, we need to make the cheap-o 'touch light' we got at home depot mood light-friendly.
First, flip the light over and remove the battery cover and screws. Inside the battery compartment, you'll see the lightbulb fixture. Take it out, and discard it and the lightbulb.
Next, open the casing. Now we need to deal with the power. Remove the piece of metal in the center of the battery compartment as well as the wire that connects it to one of the battery contacts. Solder wires onto the battery contacts as shown. You may also want to label them if you don't have differently colored wire.
We also are going to make this mood light operable via a wall outlet transformer. Drill a hole using a drill bit about the same size as the diameter of the DC power jack. Then screw it in until it is flush with the casing.
The last modification we need to make here is to add the piezo tap sensor. It is best to mount it on the plastic 'rim' for better sensitivity. I have it pictured later in this instructable mounted elsewhere, but that's only because I have had to open and close the casing during testing so much that the wires started to break. Simply hot glue it to the plastic, but make sure it does not hinder the mechanical movement on the movabke dome! (i.e. do not let it stick out too much).
Step 3: Add Power Circuit Protection
This part is a simple add-on that uses diodes to protect the wall transformer/batteries from getting fried if you have the batteries installed at the same time you use the DC power jack. You can use any blocking diodes as long as the maximum voltage rating for them is higher than the rating of the wall transformer. The part labeled 'VIN' in the unregulated power strip on the breadboard (which goes to VIN on the arduino). The part labeled 'DCPower' is the DC power jack. For some reason, the program I used to make this schematic was really picky about labels, so that's what it let me name it.
NOTE: If you don't make this circuit, you will NOT be able to keep the batteries in the battery compartment at the same time you have the mood light plugged in to the wall transformer, otherwise it will damage it.
Step 4: Add the Breadboard, Arduino, and BlinkM
Now glue down (I used hot glue) the breadboard on top of the battery compartment. Luckily for us, it happens to fit perfectly.
Now plug in the positive (+) and negative (-) wires from step 2 into one of the breadboard's positive and negative power strips.
Now we can connect the arduino and the blinkm together. Here's the pin connections:
- A5 - Clock (labeled 'c' on the BlinkM)
- A4 - Data (labeled 'd' on the BlinkM)
Step 5: The Sensors - Sound, Tap, and Light
Next in line are the sensors. The light sensor is the simplest to construct. The wire going off to the right connects to the arduino. More info on WHICH pins the sensors connect to is in the next step.
The sound sensor is a little bit harder, but not ridiculously complex. PLEASE NOTE: I have not shown a voltage divider circuit here. The 2.5V in the schematic has to be provided via something called a 'voltage divider'. It is a very, very simple circuit consisting of multiple fixed resistors, or a pot (potentiometer). Use a 50K pot for this circuit. Google 'voltage divider' and look at the wikipedia entry for help on constructing one.
EDIT 9/27/08: I ditched this sound circuit and instead used one salvaged from a sound-activated light-up pendant. The circuit here doesn't work to well; I'm not sure why, but the design is flawed ;something is not quite right. I noticed the circuit from the pendant uses an SMD LM386 op-amp. I just soldered before the resistors going to the LEDs, VCC, and GND. Then all I had to do was manipulate the values in the software a little, and presto! better working sound-responsive mood light.
At the current time, the video of the light pulsating to music is when the original circuit was used. Maybe I'll upload another showing the improved design (it looks more like it's responding to the music due to the new circuit).
I was unsure how to solder the piezo element, so I guessed and soldered it as shown. It works, though. The polarity of the piezo does not matter. The resistor is on the breadboard (not shown).
Another IMPORTANT NOTE: The values for these circuits WILL differ from yours, so you WILL need to do some tweaking in the code. If you have any questions on these values, feel free to let me know.
Step 6: Find Space for the Sensors, and Connect It All
All the connections are:
- Pin A6: Sound sensor - NOTE: for non arduino nano users, other arduino's don't have a 7th analog pin. You will have to change this in the code.
- Pin A3: Piezo sensor (tap sensor)
- Pin A0: Light sensor
Step 7: Test It
Make sure that the power connections are good; plug it in using the power adapter, and try it using batteries. A common problem is poor connections to positive and ground.
NOTE: I know that the picture doesn't show the light sensor; I just took it before I added that part.
Step 8: Program It, Close It Up, & Use It
If you want to view the code but don't have the arduino software, you can open it with a word processing program (aka wordpad for windows users).
Ideas for new functions are welcome. Please feel free to post them; I want to make this open-source. The aim of the way I structured the code is so new functions can be added easily. Some of the functions are programmed into the BlinkM by the manufacturer (ThingM), but two of them I have made; 'Sound Light' and 'Mimic Light'. Right now it has the following:
- Mood Light - Slowly fades to random colors
- Candle - Flickers like a candle with oranges and yellows
- Water Reflections - 'Shimmers' with blues, turquoises, and cyan colors
- Seasonal Colors - Turns seasonal colors (I think they are blue, green, purple, and orange)
- Thunderstorm - Flashes occasionally simulating lightning
- Stop Light - Turns from red to yellow to green and back again
- Mimic Light - Records a sequence of up to 50 on/off cycles of light (you can use a flashlight), 'memorizes' the on/off times, and then plays them back in a never ending loop.
- Sound Light - Pulsates to the sound of music
Now comes the hard part. In order to close the mood light enclosure, you have to take a few careful steps.
First, you have to line up the support springs with the small tabs on the plastic dome. Since the DC power jack is on the rim, and the wires go to the breadboard , you have to slip the plastic dome over those wires FIRST, then line up the outer rim's screw columns with the indentations on the plastic dome. Make sure all the tabs line up with the placement of the support springs, which also correspond with the screw columns on the rim, and the srew holes on the base plate. Then, once you're sure everything lines up, snap the outer rim down onto the base plate. Next, make sure no wires are stuck in the springs, or are in a place where they may in the future. This would hinder the movement of the plastic dome. Lastly, replace the screws and enjoy!
Final notes: IMPORTANT: do NOT use batteries and plug in the wall adapter at the same time. I'm not sure what will happen but I'm sure it will destroy everything connected to the power!!
Step 9: EXTRAS
This is of the 6 pre-programmed functions built into the BlinkM:
...This one is the custom sound/music responsive code I added (can you guess what song it is...?:
...And finally, but definitely not least, is the coolest (I think), and hardest function to make of them all; the 'mimic light' function: