Build Your Own Dynamic Ambient Lighting For A Media Center

Ads by Google

media center lightIf you watch a lot of movies on your PC or media center, I’m sure you’ve faced the lighting dilemma; do you completely turn off all lights? Do you keep them on full blast? Or do you use a dimmer switch to keep a dull yellow glow somewhere? Well, suffer no more.

For less than $100, you can set up an amazing lighting system that’s going to reflect what’s on-screen; if the video is a blue night scene, the lights will be blue; when a blaze of orange fire flashes on, so will your lights. Welcome to world of ambient RGB lighting.


  • RGB light strip – this is a 5 metre strip of RGB LEDs which can be bought on eBay and shipped from Hong Kong for less than ¬£20 each. If you purchase in electronics shops you’ll be paying by the metre and a reel of 5m will cost three or four times that, so buy online. These type of LED strips can be changed to any colour, but only all at once – they cannot be individually adjusted.
  • 12v power supply – the power (ampage) required depends on upon how many strips of LEDs you’ll be connecting. Each metre draws approximately 0.6 amps, but this depends on the density of your LEDs so be sure to check your particular LED strip. 3A would be sufficient for the 5m strip I linked above, and separate power supplies can be bought for around ¬£10 if you can’t source one elsewhere.
  • 3 x MOSFET N transistors – you can probaby find cheaper, but I bought a pack of 6 (type STP16NF06FP) for around ¬£10. These are used to isolate the current from the Arduino – connecting the strips directly to the Arduino would fry it with the amount of current they draw. You need 1 MOSFET transistor per LED color channel, for Red,Green, and Blue.
  • Arduino – I haven’t included the cost of this item as it’s assumed you’ll already have one, and there are a variety of clones you can buy if you can’t afford an official one.

The total cost was therefore around £40 not including the Arduino.

Ads by Google


The project consists of two parts. First we’ll be creating a basic Arduino circuit that listens to commands from the computer, and sets the RGB LEDs to an appropriate colour. The second involves using a new application called Processing¬†and Java on the computer side – to work out what colours are currently on screen, average them, and output that to the serial communications port for the Arduino to react to.

Part 1: Circuit and Arduino

The circuit we’re using is very simple as you can see from the diagram below. The LED strip should be supplied with a male plug on one end that you can place directly into the breadboard.

media center light


Your LED strip may vary, but if you look closely you’ll see 12v, R, G, B written on the rails somewhere. These strips can actually be cut at these copper points (every 3 LEDs on the ones I have), so if you want to cut the strips at the corners of your TV you can safely do that – you needn’t use the whole 5m either, so you may have some left for a future project. Connect the positive 12v directly to the external power supply.

dynamic ambient lighting

The MOSFETs have three pins; gate, drain, and source. The gate is like the electronic switch which the Arduino will control. This then determines the current flowing between the source and drain. The drain of each MOSFET should be connected the ground of the Arduino, and the ground of the power supply, while the source connects to the LED strip channels.

dynamic ambient lighting

When you’ve completed the circuit, download and run this test code (originally from LadyAda, pins modified). You should see your LED strip swirl through a variety of colours.

dynamic ambient lighting

Part 2: Processing

Download Processing and run. You may be surprised to find it looks almost exactly like the Arduino development environment; that’s because the Arduino environment was based on it, though they both perform different functions. Grab this codeoriginally by Silicon Republic but heavily modified by me to make the screen size settings automatic and with better¬†color¬†representation¬†– ¬†and take a moment to look over it. Basically it uses a Java class called Robot to do a screen capture every 10ms; it then picks out every odd pixel and averages the total color. If performance is an issue for you, increase the skipValue variable to 3 or 4 to skip more pixels – the overall effect should be the same but it’ll run faster as it examines less pixels. Finally, I added a filter which helps to saturate the¬†color¬†by increasing the maximum and decreasing the minimum RGB values found (without this, I found the¬†colors¬†to be too white).¬†

Run the app; the first time, you will probably get an error as it tries to access the wrong serial port.

dynamic ambient lighting

Check the debug window for a list of current serial ports, and note the number next to what your Arduino is plugged into. In my case on a Mac, the USB connection is port 4. Change the number in this line to the correct port:

port = new Serial(this, Serial.list()[4],9600); //set baud rate

Save and re-run; you should see a small window pop up – this represents the average¬†color¬†of everything on-screen. Launch a painting app or something with strong¬†colors¬†to test it, otherwise it’ll probably just display a murky shade of grey. Stop the application when you’re done testing as we need the serial port access to program the Arduino.

media center light

Lastly, load this code on to your Arduino. Instead of sending random colors to the LED strip, this code reads the values from the serial port (which Processing is outputting to). It’s fairly easy to understand, the only difficult part may be the use of a marker in the serial data:

if (Serial.available()>=4) {
if( == 0xff){
red =;
blue =;

This ensures we read the correct byte values¬†– the Processing app outputs a marker as a “breakpoint” between each set of values so that the Arduino won’t get out of sync and think that the green value is for blue etc.

Once the Arduino code is uploaded (there should be no output on the LED strip initially), then you can load and run the Processing app; immediately you should see your ambient light working.

Here’s a video demo of how it worked out for me with some random trippy music video.

What do you think?! While it isn’t quite as impressive as something that analyses each part of the screen and uses individual LED pixels, it is a lot cheaper and a lot brighter. The only downside to this is that everything must be run on your media center computer – it won’t work with regular TV broadcasting or your Xbox 360, for example. If you have any problems, questions, or suggestions then please ask away; or perhaps link to a video of your completed setup.

Ads by Google

18 Comments - Write a Comment


Arxadius Stark

Interesting read. Might give it a try when I get some time on my hands. c:



This looks awesome. I may look into building this when I have some spare cash


Arben Myrtaj

Holy sh*t, that’s awesome.


James Maciel

that looks really cool, nice job


Ron Lister

Looks like a fun and fairly straight forward fun project, James. Thanks.


Junil Maharjan

Arduino seems to be getting much coverage nowadays. It is so useful. Can’t wait to get my hands on one of these.



What about fiber optic? That stuff looks awesome.

Muo TechGuy

Hmm. The problem with fibre optic is that it only has a concentrated beam of light at once end. It couldn’t really be used as a light source to project light around the room. Perhaps you mean electroluminescence (EL) wire?


druv vb

Thats an interesting light work. But yours seems more like party lighst. I have done almost the same, using only a 12v power source and light strips. I’ve a green one just below the surface of my table for illuminating the keyboard, mouse and anything below the table. A blue one at the back of the table, allmost like a backlight for the screen.
And will be doing the same with my tv set in the living room. And all of them are running at only 6v, for a more dimmer and cooling light expereince. Full 12v power is too bright.



Hello all,

I built a small java app to control arduino based lighting system. At the moment it has three modes. Ambient lighting, Preset sequences (in which you can modify fade setting, interval for color change. more color sequences can be hard coded at the moment) and manual color selection. It minimizes to the system tray and there is a function to turn the lights on and off.

I would also like to make a setting for how it scans the screenshots in ambience mode, i found some code that just scans the edge of the screen and i reckon it would be a good setting + minimize cpu usage.

The code is open source and is available on Github here: and a built jar with library dependencies is in the store folder.

Feel free to use it in the tutorial and contribute to the project if you a java wizard.

Also if anybody know how to do this image procesing on the gpu with c++ (if it is even plausible) please get in contact with me.


James Bruce

That’s fantastic, thanks Michael. I’ll see if I have time to write about it again some time.



great mod, not as white anymore because of your filter but now black screen shows red color on the strip. With the original it was just no light.

MakeUseOf TechGuy

Hmm, curious. I wonder if it’s 100% black or there’s a tiny bit of red remaining somewhere? The filter basically just amplifies the hue by raising whatever RGB colour is strongest and lowering the weakest – so any tiny amount of red if present would be dominant. It could certainly be improved, I jsut tend to prefer stronger colors. Perhaps an additional filter that ignores everything if the values are less than 55 or something…


Thanks I finally understood how your filter was working (I’m not a programmer) because of that sentence:”The filter basically just amplifies the hue by raising whatever RGB colour is strongest and lowering the weakest”.
I added this after your filter and it fix my problem, thanks
if(r <= 50){


no it doesn’t work. ok it works when it’s black completely but when it’s totally dark sometimes it’s blue or green. It’s really annoying, I took of the =0 filter.



hiiee everyone. I have a question does this light system work when we play mp3 files?

James Bruce

No. The light reads on-screen color values. Unless your music has a video, it wont react to music.



hello i try to do it with transistor and the color change but not soo much and not the right color of the screen the test code worked well!!

Your comment