Arduino Musical Lighting System
A first project with the Arduino Uno computing platform.
22 Feb 2011
This project came out of a desire to light up my dorm room in college. The common dorm room usually comes with a little fluorescent lamp in the middle of the room, sufficient to provide general illumination, but just barely. My room in Next House was no exception. Yet the idea of buying a little table lamp (why are they so expensive?) was unappealing. I had to get some lights for my room. But there was a desire to not only install additional lights in my room, but also to bring a bit more flavour and piazza to my room. Afterall, I was in a tech school. Earlier on in the semester, I had acquired a set of three 20W Halogen lamps and they added much warmth and comfort to my room (love Halogens!). Still I wanted a bit more dynamism and colour in my room.
Then in the early spring of 2011, my dorm held its first event in a long time - Impulse, which was a party at the basement. The cool thing about the party were the lights - a $2000 investment that the house had given to a group of students to design and build a party lighting system. It was extremely successful, and made me recall the amazing dancing lights I saw at another dorm room a few months back (TEP for the record). It was then when I decided to build my own lighting system.
Update: Just less than two months after the idea was planted in my head, the first incarnation of the lighting system was born. The result is showcased here as a Vimeo Video. For more information, refefer to the project log and notes below.
Music Visualizer with Halogen Lights (First Version) from Ggy on Vimeo.
The goals of this project were straightforward. Having not much experience with microcontrollers before, I decided to adopt the Arduino development platform using the Arduino UNO board running a ATMega328 Microprocessor. Arduino was chosen due to its low cost, ease of use, fantastic documentation and versatility. I also decided to try out first hand the new high-powered LEDs which incredibly expensive just a few years ago.
The principle of the music visualizer is simple - stero audio from a 3.5mm stereo jack is sent from a computer or an MP3 player into the Analog input of an Arduino board. The microcontroller reads out the waveform and performs a frequency decomposition into several different frequency bands. The microcontroller then takes the amplitude of each frequency band and uses it to modulate the brightness of one of several ultrabright LEDs using Pulse Width Modulation. Since the microcontroller cannot output more than 50mA, MOSFETs are used to switch the high-powered LEDs, and eventually, Halogen incandescent lighting.
These are the goals of the project:
- To design and construct a simple and portable lighting system with ultrabright LEDs
- Allow modular implemention for extension to other lighting systems, e.g. Halogen lamps
- Learn to use and program the Arduino microcontroller system
- Implement a basic but effective lighting algorithm for first version of system
- Incoporate more complex and fancy lighting algorithms for subsequent versions
With these few ideas in mind, the project begins!
Arduino Arrived today! I bought an Arduino Uno on Amazon.com for $29.95, but I had a $20 discount voucher which I spent $10 buying. Unfortunately I can't work on anything else now because I'm still awaiting some other components. Spent some time reading up about the basic functionality of the Arduino.
2nd Mar 2011
After some initial research, it was apparent that standard implementations of Fast Fourier transforms run not-quickly on the Arduino. However, I discovered that there exists a 7-band graphic equilizer filter which will be able to filter out the 7 frequency bands of my input audio, and it all comes nicely in a small 8-pin IC! This is the MSGEQ7 graphic equilizer filter chip. I couldn't find a cheaper and easier place to get the MSGEQ7 graphic equilizer filter so I ordered some from Sparkfun electronics. The MSGEQ7 is $4.95 each.
I havent decided which LEDs to buy yet, but it seems that the LEDs I am currently interested in run at about 3V (varies with colour) and (have conflicting reports) of it being driven from 300 to 700mA, at which they run quite hot. Regardless, there is no way the Arduino output pins can supply greater than 50mA. In order to switch the bright LEDs, one could use a transistor like the TIP102 or TIP120 (darlington transistors), but I decided to go for the commonly avaliable N-Channel MOSFET RFP30N06LE. It is rated for 60V at 30A and is a huge overkill for the project but they're $0.95 each. If all goes well, I should be getting the components in about 1 or 2 weeks.
Next up on order would be the powerful 1-3W LEDs, which will probably be from DealExtreme.
4th Mar 2011
After sorting out the intial plans for how I would want to make the lights, I ordered some powerful LEDs from Dealextreme. I do not know the exact power rating but people claim to have driven the LEDs to 700mA, which works out to be over 2W input per LED. The plan is to have 6 powerful LEDs of different current corresponding to the six output frequencies from the MSGEQ7. These will be: White, Red, Yellow (white with gel), Green, Blue, Purple (White with Gel). I also purchased a few other spare components listed here:
- 3W Multicolor LED #4530 $2.74 ea.
- Red CREE LED Emitter #1776 $3.64ea.
- Blue CREE LED Emitter #1775 $4.11ea.
- Green CREE LED EMitter #1777 $4.21ea.
- White CREE P4 LED Emitter #1302 $2.93ea.
- 5mm UV LEDs x20 #2398 $3.07 for 20
11th Mar 2011
Today I finally got started working on the project since I had received some of the components and could begin. I got a breadboard and started laying out the circuit. The intial plan is to use the MSGEQ7 spectrum analyzer which is a 7-band filter and will output the amplitudes of each frequency band based on a driver frequency.
Settng up the circuit was relatively straightforward. One channel of the stereo input was used and the wave sent to the graphic equilizer filter. After a few quick initial tests, it was determined that the circuit was working! The MSGEQ7 outputs the amplitude in 10 bits. Right now I'm just dividing by 4 (fast binary operation) and sending it as a 8 bit value to the Arduino Pulse Width Modulation output. Since the Arduino only has 6 PWM outputs and I do not wish to use a multiplexer for now, I have connected 6 LEDs to the Arduino output with a resistor in series since the PWM pins output 5V.
The result is as follows - the circuit works! The most imporant problem for now is that the output of the LEDs is are not 'contrasty' enough. This is expected since the brightness curve is linear. More work will be done soon. School beckons.
20th Mar 2011
A quick improvement. I didn't have much time so I just did some small tweaks to the Arduino code. This has mostly got to do with the 'contrast curve' After some experimenting and looking at various graphs, I've settled on a Sin(Sin^4) curve.
I also found a white LED and used it for the bass. I recorded a short video of it in action. Now all I need is to await the bright LEDs to connected up via the MOSFETs. :)
29th Mar / 1st Apr 2011
Have received the bright LEDs from dealextreme! This week (at least till Wednesday) is a bit busy so I hope to begin at least wiring up the LEDs and the mosfets within the week :) ...
[Update 1st Apr] It's April Fool's today! However, not much stuff was going on in school. I headed over the MITERs, a little workshop in my school and soldered the LEDs to wires for easy connection, and also did some tests on the current I should be sending into the LEDs. I do not know exactly what the part numbers for the LEDs are except that they are CREE LEDs. The specifications actually seem to read that they are capable of 750mA input each at varying voltages, but I've heard reports that they run really hot at that current, and most people are fine with 300mW. So I plan to run them at 350mA each. The LEDs are really bright and I'm pleased with them. Now it's time to make a mount to hold all of them together!
11th Apr 2011
The first phase of the project is complete!
LED Music Visualizer by loneoceans labs from Ggy on Vimeo.
And the setup works well! Extensions to come to extend control to normal light bulbs around my room.
Late Apr 2011
TIP120 Darlington Transistor
Since the LED lights were so successful, I decided to do an extension and wire up the set of 3 20W Ikea halogen bulbs to the setup. I think the lights will be nice if they respond to the bass, so I spent an hour or so wiring up a quick circuit to put in series with the halogen lights and the 50W 12VAC halogen transformer. I had ran out of MOSFETs so I decided to give the TIP120 a try. The TIP120 is a common NPN Epitaxial Darlington Transistor, which is basically two transistors together, allowing a huge current gain (i.e. use a really small current to switch a big one). The darlington configuration allows a much higher switching load compared to just a single one.
TIP120 wired to Halogen Lights - Do not use this, a MOSFET performs much better! More details below.
This particular transistor is rated at 60V 5A, with Emitter-Base voltage of 5V and DC Curret Gain 1000. The 12VAC was rectified via a bridge rectifer and the output connected to the TIP120, which was mounted on a heatsink. The basic wiring diagram is as above. Note that it is important to connect the - of the circuit to the ground of the microcontroller. With everything set up and the Base connected to the PWM output for the bass frequencies, the lighting system was switched on.
Unfortunately, the setup performed poorer than expected. The TIP120 got really warm quite quickly even with heatsinking and the lights never really turned off - they just got brighter and dimmer. It was clear that the particular transistor I had was not optimal for the task - a Mosfet would be better. I used another RFP30N06LE MOSFET (60V 30A Logic Level) to control the Halogen Lamps and put everything together on a nice heatsink (mostly for the bridge rectifier which was a 34A 800V one I had lying around) and connected it up to the lamps and Halogen transformer. The circuit is as follows:
Junked the TIP120 and used the 30N06 N-Channel Mosfet. Also added a switch allowing me to toggle between Always-On and Modulated. Works great!
This new circuit is essentially identical to the LED setup. It works great and shows the limitations of the TIP120 darlington.
7 Sept 2011
IRFP460 120V Incandescent Bulbs
I got back to school on the 2nd of September and immediately got started on working on a new extension for my lights. This took a single 4 hour session as well as two more trips back to the workshop to get the circuit debugged. The idea this time was to use the same 5V PWM signal from the Arduino to power an array of tungsten bulbs - not from a 12V supply, but bulbs from the mains. This will allow me to use a row of cheap and nice light bulbs and should work great with the bass. Junk materials were used - a left-over polycarbonate board was machined to hold 4 bulb holders and the entire setup raised on wooden blocks. The heatsink was then mounted with two bolts and the small 12V supply with cable ties.
The question then is how to switch 120V with 5V? The easiest would be to use a logic level Mosfet with a gate trigger of 5V. Unfortunately, I have not come across any power Mosfets capable of switching 120V with 5V. Also, I had some very nice IRFP460 Mosfets lying around, good for 500V at 20A, and decided to use them. :) The problem is that these normal Mosfets require around 10 to 20V to switch.
I used 3 100W 230V bulbs (had to use a 25W 120V yellow bulb because I only had 3 100W bulbs) running on a 120V line to give the bulbs a warmer glow. In comparison, the bulb in the background is a 72W halogen so you can see how comparatively warm the 100W bulbs (under-driven at 25W) are, exactly the intended effect!
The original solution called for using a simple N-Channel 2N7000 Mosfet (very cheap and very common) to trigger the gate. The problem is that N-Channel mosfets should act as a 'low side' switch and wiring them in series with my IRFP460 would create a logic inversion, i.e. no signal from Arduino --> lights on; signal --> lights off; which is not what we desire. Eventually I settled on a rather unusual way of using an NPN transistor (2N2222, again another ubitiquous transistor) trigger by an arduino to a resistor-voltage-divider. The 2N2222 sends current to this divider from a separate small 12VDC power supply which triggers the IRFP460.
Simple and very effective. The bridge rectifier and Mosfet were mounted on a small heat sink and a spare 12V fan was attached above the heat sink for some cooling. The rest of the electronics were simply component-soldered directly without the use of a PCB (bad practice!), and turned out to be quite messy, something I will try not to repeat! This mess of wires was conveniently hidden under the heat-sink. Finally, a switch was added to allow the lamps to be (1) Turned off, (2) Turned on continuously and (3) Controlled by the Mosfet. This extension was completed on 6th Sept 2011 and now sits happily at the top-shelf in my room.
Total Project Cost (this includes a pile of spare components not used in the actual project):
Arduino Uno (after discount) - $19.95
Sparkfun Order for MSGEQ7 and MOSFETs - $30.31
Dealextreme Order for LEDs and other components - $38.18
General Project Links
http://www.deepdarc.com/2010/11/27/hacking-christmas-lights/- Hacking Christmas Lights using an Atmel microprocessor
- Arduino and BlinkM Music Visualizer
http://www.arduino.cc/ - The Arduino Website
- Arduino FFT
- LED Visualizer Project
http://www.silvercg.com/2011/02/14/arduino-rgb-led-winamp/ - Simple Arduino project
http://fftarduino.blogspot.com/2011_02_01_archive.html - Another FFT Arduino Spectrum analizer
http://projects.mathfarmer.com/home/12-band-color-organ-rgb-led - 12-Band Color Organ
http://siliconrepublic.blogspot.com/2011/02/arduino-based-pc-ambient-lighting.html - Arudino Backlighting
Using the MSGEQ7 Graphic Equilizer DisplayFilter IC
http://scottrharris.blogspot.com/2010/12/hacked-ge-christmas-lights-color-organ.html - Ardino+MSGEQ7 GE Christmas Lights (source code here)
http://skoba.no-ip.org/msgeq7/- Connectng the MSGEQ7 IC to Arduino
- Arduino Forum
- Arduino Forum
- Color Organ Shield Arduino
Powering powerful loads using TIP 102/120
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1294857483 - Arduino Forum
http://arduino.cc/playground/uploads/Learning/solenoid_driver.pdf - Solenoid Driver from Forum Link
http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/ - Potentiometer
http://www.4p8.com/eric.brasseur/vtranen.html - On Transistors
http://101science.com/transistor.htm - Introduction to Transistors
Signal Processing and FFT
- DSP Guidebook
http://www.dspguide.com/ch8/6.htm - DFT
- Goertzel Algorithm
LED Cube Displays
http://hypnocube.com/instructions/ - Hypnocube
http://hacknmod.com/hack/tutorial-how-to-make-led-cubes/ - How to make LED Cubes
http://www.atomicvpp.com/wpblog/2007/11/25/led-cube-project/ - LED Cube Project
http://www.instructables.com/id/Led-Cube-8x8x8/step71/Hardware-debugging-Broken-LEDs/ - 8x8x8 LED Cube
- LED Cubes with great effects
Links to buy stuff
http://www.sparkfun.com/products/10024 - The MSGEQ7 for $4.95
http://www.dealextreme.com/ - Reasonably priced powerful LEDs
http://ledsupply.com/endorstar-1up.php - Other LEDs
Back to main page
(c) Gao Guangyan 2011
Contact: loneoceans [at] gmail [dot] com