Skip navigation

Alright, time for my first non-SaikoLED/Artemis post!

I received a comment on my Youtube channel asking for the code to one of my absolute favorite projects so far.

Featured below is a commercial for the Philips Ambilight technology. This is an absolutely fascinating feature on new TVs that actually lights up the area surrounding the screen, based on the most prominent color currently being shown. Note the use of purple/green that they demonstrate for The Hulk.

I was overjoyed when I discovered that there was an existing DIY Ambilight clone featured at http://www.lifehacker.com.

Basically, a hobbyist by the name of Rajarshi Roy had created this clone by writing his own screen capture software in Processing, and then using that to send the color data to an Arduino, which then drove a strip of RGB LEDs. He used a strip that was being sold at SparkFun’s website. I have an inexplicable dislike of ordering things online, so I decided to eat the extra cost and buy a Radio Shack RGB LED strip. This was, possibly, the worst mistake I could’ve made.

The SparkFun strip used four wires and was very well documented. The Radio Shack strip used three wires, and was incredibly confusing with no documentation whatsoever. I used Rajarshi’s Processing code and Arduino code at first, as a base point. Of course, it didn’t work. It wasn’t written for the hardware that I used. I then modified Radio Shack’s example code, which sent hex values to the ICs that drove the RGBs. It then used timed pulses to push data across the strip, lighting them up with the specified color. I don’t know this because it was in the documentation. I know this because I spent an entire night/morning reading through it and barely grasping the concept. I still don’t have a concrete idea on how it works. Instead of advertising it as a DIY component, they should honestly just say “Radio Shack – 1 Meter RGB LED Bright Flashing Rainbow Strip”, as that’s all the default code does.

I cut out all of the bits of code that sent all of the pretty colors, and then took bits of Rajarshi’s code and plugged them in. I made progress! The lights came on and actually reacted to the computer. However, everything was pink. No matter what I did, everything was pink. I gave up for the night, and literally woke up four hours later with the answer popping into my head. The values are reversed. It’s not an RGB strip. It’s a BGR strip. I swapped the values around a little and tried again…

Ohhhhh yeah. I then decided to test it out using Winamp’s visualizer, and the DI.FM Epic Trance broadcast.

BEAUTIFUL. I loved it! To this day, the Arduino and RGB strip are permanently mounted behind my TV. It’s excellent for movies and video games (Seriously, firing the Plasma Gun in Quake 3 is so much fun. The whole room lights up.)

I’ve attached the two files I used below. The Arduino code (Named strip_1m.ino because I never bothered to rename the Radio Shack file), and the Processing code. Enjoy!

QUICK NOTE : I do NOT take any credit for the hard work put behind Rajarshi Roy’s work. All I did was make the program play nice with the Radio Shack RGB strip. If you’d like to thank anybody, thank the man himself right here.

Also, please keep in mind that you’re going to need both Processing, found at http://www.processing.org/

and the Arduino programmer itself, along with an Arduino, of course. The programmer is found at http://arduino.cc/en/main/software

Both programs look nearly identical. Always double check to make sure which one you’re in!

The Arduino code:

https://www.dropbox.com/s/y1wy39kdxj57zcd/strip_1m.ino

The Processing code:

https://www.dropbox.com/s/bw8d22g9ear5tjt/ambilight.pde

 

Advertisements

5 Comments

  1. This. Is. Awesome. I’ve got a sculpture that I’m trying to light with a similar, except I’m using a PING))) sensor. You can see part of my project here : http://arrowrootmedia.com/tag/maker-faire

    The code I’ve got takes the Ping))) sensor value and converts it into inches and centimeters. So I’d like to for the distance to drive the colors in an analog type fashion.

    How would you suggest I take this “centimeters” variable from my sensor and covert it into something this?

  2. Hey, dude. Thanks for posting this. I came across this page about 3 weeks ago, and it was the jumping point for an Ambilight clone of my own. I now have a sketch for both Arduino and Processing that will:
    1) Take the average color in vertical thirds of the screen and send them to the strip as follows – let’s say your screen is showing red on the left, blue in the middle, and yellow on the right. Your LED strip (same you’re using) would display
    Red Red Purple Blue Blue Blue Blue Green Yellow Yellow. (L L L/C C C C C C/R R R)
    2) Take the average color of 10 vertical sections of the screen and send each color to its corresponding section on the 10-section LED strip.

    I thought I’d stop by to say thanks for getting me started and to offer the sketches in gratitude. Email me if you’d like them.

    – Joshua

  3. Hey… Thanks for writing this up. I’m pretty new to arduino and am having problems. I have both my Arduino Mega 2560 and processing up and running. I can tell the two are communicating with the RX light. I have my RadioShack led light strip plugged into the Vin and GND ports as well as A0 for the data wire. I’m supplying 12V to the Arduino through the power port. Everything compiled/ran just fine but I’m not getting any light. The strip is totally dead. When I load the original Radioshack sketch everything works fine… I get the disco lights. Just wondering if I might of missed something simple? I didn’t modify the code (either of them) in any way…

    Thanks a lot for any help provided
    APG

    • Hey there. You’ve got the pinout correct, and it SHOULD work just fine with the unmodified code. However, I’m not familiar with the Arduino Mega. I think that perhaps my code has some Uno-specific setup that might throw things off? I would suggest cutting and pasting relevant bits of code from my program into your working Radio Shack sketch and see if that helps anything?

        • Andrew
        • Posted September 4, 2013 at 2:29 pm
        • Permalink

        Ok… did some digging and found others that were having problems with serial communication between Processing and the Mega 2650. According to a post on the Processing website (http://forum.processing.org/topic/serial-with-new-arduino-mega-2560) you need to disable RESET and wait some time after the port is opened. I did this by adding a .10uf capacitor between the Reset and Gnd pins on the arduino. I also added a one second delay after the port is opened. Everything seems to now be working perfectly. Awesome!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: