loading
Picture of 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!

 
Remove these adsRemove these ads by Signing Up

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

Picture of 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

Picture of 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

Picture of Find space for the sensors, and connect it all
DSCF6537.JPG
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

Picture of Test it
DSCF6495.JPG
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

Picture of Program it, close it up, & use it
DSCF6537.JPG
DSCF6490.JPG
The code I used uses a library created by Tod E. Kurt (www.todbot.com/blog) 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:


shooby6 years ago
COoOOL DO you have a total cost estimate, I don't think I saw one.
RPisces (author)  shooby6 years ago
Well, if you already had some things such as the arduino (or just the microcontroller with voltage regulator, ICSP, indicator lights, etc) and the breadboard, it would cost you about $30. Generally speaking, if you had most of the common components needed to make this mood light, you could get away with spending less than $50 on the whole thing. But if you had none of the parts needed to make it (arduino/atmega168,most/ all bare components, the breadboard, blinkm, wall adapter) then you might end up spending up to $80. Does that help? I should probably add that in...
Earlack RPisces6 years ago
Do we really have to use this exact type of LED ? Would it be possible to adapt this to Luxeon LEDs ? Cause I have some laying around...
RPisces (author)  Earlack6 years ago
Yes. But it would probably make the code 5x as long, require 5x more work, and would be 5x as hard. Remember, the BlinkM isn't just an LED, it's an SMD microcontroller ATTACHED to an LED, and it already 'knows' all the fading sequences. Although, it WOULD be very easy to adapt the two functions I programmed myself using your luxeon LED's, because the only color being used is white.
Amazing! This looks like great! Very detailed instructions! 5 stars! The only thing I would like to see is a video of the end result. Other then that, Great Instructable! -Joe
RPisces (author)  joejoerowley6 years ago
Videos? Done.
Great! Looks really nice! I would love to build one and stick it next to a strobe light haha.