Introduction: Interactive, Open Source Mood Light

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

This project can be pretty inexpensive if you use the right stuff. I will note alternate parts that can be used to make it less expensive to make. I just used some components that are a little more expensive, due to the face that it makes the construction process a little easier.

  • The light source:

BlinkM RGB I2C-Controlled LED

  • The controller:

Arduino microcontroller - I used an ' Arduino Nano ' because I needed something that was really small, due to the amount of space available inside of the 'touch light' used to house everything

  • Housing:

I considered many different enclosures for this mood light, and I finally settled on something we're all familiar with: those cheap-o, white, ' touch dome lights '. I found a two-pack at home depot for only about $4. The amount of space in these lights is more than enough to fit all the components, if you do it right.

  • Power/Connectors:

At the beginning, I thought it would be cool to run this off of battery power (because the housing already has, conveniently, a battery compartment), but it's not that practical if you're going to be running it long periods of time. Instead, I used a 5.5mm DC power jack from radioshack with a 12V 150Ma transformer I had lying around. The regulator on board the arduino brings down the 12 volts, and 150Ma was plenty current to power everything. For wire, I just used whatever I had around. Be sure to use solid core wire, though.

  • Components:

The components are used to make the three sensors for the mood light: the sound sensor, the 'tap' sensor, and the light sensor. For the sound sensor, you'll need:

- 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
- Diode

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)

  • Other

I used a breadboard because I didn't really want to solder a lot. I also used a lot of crimped connector wires to make all the connections more secure, but those are 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

Before we add the breadboard, we need to insulate the battery contacts from the metal breadboard backing (that is, if you have the metal plate stuck to yours. If not, skip this step). Put some scotch tape over all the metal contacts to make sure they are insulated. We don't want any exposed wire.

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)

And one you've done that, connect the UNREGULATED VCC (+) to the 'VIN' pin on the arduino, and the REGULATED VCC to the (+) pin on the BlinkM. Then connect GND on the arduino and BlinkM to the GND on the power strip, and bridge both GND power strips together. BE CAREFUL not to mix up these connections, or you could fry 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

This part shouldn't be too hard. The 'touch light' casing has ample space to fit everything we need to fit. I placed the sensors wherever they would fit.

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

Make SURE you don't accidentally connect the (+) leads of the sensors to the unregulated power strip, or you WILL fry them.

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

The code I used uses a library created by Tod E. Kurt ( and the makers of BlinkM (ThingM). I will try to add notes in the code when I can to make it more understandable; I'm kind-of busy at the current time. You must have the code library (the file labeled "BlinkM_funcs.h") opened in the arduino software when uploading the code or it will not work.

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

Tap lightly on the translucent dome to change functions at any time. There is one exception to this rule: when you reach the 'mimic light' function, it will flash green. If you tap on the dome while it is flashing, it will go to the last function ('sound light'). If you just wait, it will go to the 'mimic light' function. When you get to the 'sound light' function, you cannot change functions and go to the first one, due to the way it reads the sound sensor.

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

Here are some videos:

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: