Pinterest Stumbleupon Whatsapp
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.

Components

  • 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 What Is Arduino & What Can You Do With It? [Technology Explained] What Is Arduino & What Can You Do With It? [Technology Explained] If you're like me, tinkering with electronics is something you'd really like to be able to do - in theory at least - but the realities of time constraints, lack of knowledge and few rewards... Read More – 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.

Introduction

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

Ads by Google

 

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(Serial.read() == 0xff){
red = Serial.read();
green= Serial.read();
blue = Serial.read();
}
}

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.

  1. paul
    March 22, 2016 at 7:48 am

    hello. do i need to chgange the battery if i cut the strip led?thank you.

    • James Bruce
      March 22, 2016 at 8:00 am

      There's no battery in this project....

  2. richardvansoest
    February 7, 2016 at 11:57 am

    Hello i have already built an ambilight with ws2801 pixels (100 of them) but i like to have some other lighting in my room act also on what is on the screen.

    I used processing 2.1 and i get an error window.height is no longer used or somthing like that (on my test machine i have 3 monitors)

    Now i use processing 3.0 and the result is the same.

    How can i change the processing scheme to use newer processing ide ?

    I use on my tv setup a arduino uno with 2 strands of 50 led pixels (from rita.en.alibaba.com)
    in combination with Kodi.tv and boblightd

  3. John
    February 5, 2016 at 5:35 pm

    Hi again, would it be possible if you could upload the wiring scheme including the sensor and buzzer.I'm afraid to do it because I don't have much experienced with electronics.

  4. Davin Lee
    October 29, 2015 at 4:02 pm

    Hello,

    I've been trying to start this project except I feel like I'm missing some material for it. The diagram shows some sort of external energy source that I am not aware of. What is this component called and where can I get it?

    Thank you

    • James Bruce
      October 29, 2015 at 5:14 pm

      12v power supply, in the equipment list. However, this guide is quite old. Since then Neopixels have become significantly cheaper, which gives you individual control of each LED rather than just a solid block of color. Check out my newer guide on making DIY ambilight, same principle, but far better end product: http://www.makeuseof.com/tag/make-ambilight-60/

  5. giorgos
    May 5, 2015 at 7:39 pm

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

  6. subho
    April 26, 2015 at 4:50 pm

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

    • James Bruce
      April 27, 2015 at 7:37 pm

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

  7. Alain
    April 14, 2013 at 1:37 pm

    Hello,
    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.
    Why?

    • MakeUseOf TechGuy
      April 15, 2013 at 7:47 am

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

    • Alain
      April 17, 2013 at 12:45 am

      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){
      r=0;
      }
      if(g<=30){
      g=0;
      }
      if(b<=30){
      b=0;
      }

    • Alain
      April 17, 2013 at 2:19 am

      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.

  8. Michael
    January 6, 2013 at 4:04 am

    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: https://github.com/micwallace/wallaceRGB 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.

    cheers,
    Michael

    • James Bruce
      January 7, 2013 at 10:04 am

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

  9. druv vb
    December 21, 2012 at 4:12 pm

    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.

  10. Griffin
    December 17, 2012 at 3:34 pm

    What about fiber optic? That stuff looks awesome.

    • Muo TechGuy
      December 17, 2012 at 3:42 pm

      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?

  11. Junil Maharjan
    December 16, 2012 at 5:14 am

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

  12. Ron Lister
    December 16, 2012 at 3:08 am

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

  13. James Maciel
    December 15, 2012 at 12:10 am

    that looks really cool, nice job

  14. Arben Myrtaj
    December 14, 2012 at 7:49 pm

    Holy sh*t, that's awesome.

  15. Scutterman
    December 14, 2012 at 6:54 pm

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

  16. Arxadius Stark
    December 14, 2012 at 6:18 pm

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

Leave a Reply

Your email address will not be published. Required fields are marked *