Hey Guys!
A lot of things have changed since I began my project and I didn't expect so many ideas, comments and improvements.
Because it is much easier to build an Ambilight than in my instruction, I decided to update my instructable. First of all, there are, of course, many other solutions out there. Checkout this link, it's easy and really cool:
http://hackaday.com/2011/10/05/adalight-ladyadas-ambilight/
THIS instructable is not up to date. If you want to find out about my new approach of building a 30 channel ambilight just search for my other instructable dealing with this topic or click this link:
http://www.instructables.com/id/30-channel-LED-RGB-Ambilight-Clone/
Remove these ads by
Signing UpStep 1Java Microcontroller LED TV Ambient Light
INSPIRATION
A few weeks ago I came across a blog entry by SiliconRepublic (Roy). His original post can be found here:
http://siliconrepublic.blogspot.com/2011/02/arduino-based-pc-ambient-lighting.html
The author wrote a small Processing sketch that sums-up all RGB values of his computer display, calculates the mean values and sends them via serial connection to a micro controller (in his case an Arduino). The Arduino controls a strip of RGB LEDs.
That is an easy assembly and really useful at the same time. It appreciates your way of watching movies a lot. My aim was to enhance his ideas so I could have something like the Philips Ambilight: Different colors on different positions of the screen. I also wanted a little user interface so I could easily change parameters without changing my source code.
Because I am not familiar with Processing I used pure Java in this project. I guess you can easily transfer my program to Processing due to the fact that Processing and Java are really similar.
Beside that Java application the other main component you need to accomplish this task is a micro controller (perhaps two?) to operate the LED strips.
ambientLED.zip669 KB| « Previous Step | Download PDFView All Steps | Next Step » |





















































I am desperate with my MEGA2560 and the SW for this project.
There is a package in all of the java-files "package de.zucizu.ledlights" which can not be found by the compiler. So I deleted this in every file and the compiler is actually doing his job.
Everything seems to work however the LED / PWM is not working at all with the provided Arduino-SW.
If I am using a port-sniffer I can see, the RGB values sent by the Java app to the arduino, I do also see the flickering of the Rx LED... but the brightness is not changing.
Using a terminal programm and send it manully it is working fine at least for LEDpin 13 (not testest the other outputs yet)
Is this because of the missing package "package de.zucizu.ledlights" ?
Or is there anything else what I miss here ?
Thanks for your help
Actually I've build another one for somebody and I used an Arduino Mega, too. I had to change some code because I haven't tried it before and couldn't confirm if it works or not. But now everything works fine. I've packed everything into a jar file to use it immediately out of the box. But you can also see the source code, because I added them to the package. The Arduino source code is different now. But just have a look.
http://uploaded.to/file/9h8d5n1s
The order of bytes sent to the μC is the following:
First 0xFF to synchronize and then left RGB and then upper left RGB.
After that 0xFE another synchronisation, Upper right RGB, right RGB.
And Arduino Pins:
Left RGB = 2,3,4
Upper Left = 5,6,7
Upper Right = 8,9,10
Right = 11, 12, 13
Of course you can change it just how you need it in the source code. Hope I could help you.
Just ask if there are any problems left.
I am wondering, how the synchronization is working anyway ?
Let say the PC is sendingcontinously some data ...
00 00 FF 00 00 00 FE 00 00 00 00 ...
You don't know the exact timing when the uC starts reading the data.
If the uC missed the e.g. FF for the left - lefttop side, the next FE which was actually meant as a color value is miinterpreted as start value for right - top right.
So to avoid this we need to adjust the max value in the JAVA app of the sent data to 253 instead of 254 and 255.
And even the JAVA is not sending FE and FF as color value anymore, we still do not know when the inputBuffer of the uC is loaded with just color values
You wrote:
>Let say the PC is sendingcontinously some data ...
> 00 00 FF 00 00 00 FE 00 00 00 00 ...
> You don't know the exact timing when the uC starts reading the data.
> If the uC missed the e.g. FF for the left - lefttop side, the next FE which was > >actually meant as a color value is miinterpreted as start value for right - top right.
It won't be misinterpreted. remember the boolean called 'left'. If the uC misses the FF it would jump into the if-query asking for left, because left is true. then it would read a byte and see that the byte is not FF. nothing would happen. That would continue as long as not FF is being sent.
So everything is working fine with the following method
(I am using eclipse for the JAVA)
0. Put a breakpoint in the JAVA before the RGB data are written to the Outputstream
1. start the app with the debugger
2. select in the JAVA app the COM port and activate the port
>> Now here I am experiencing that LED13 goes ON and remains ON even
no data is sent ?
3. Wait a couple seconds (e.g. 10s) and let the debugger run for another
turn
>> All LEDs are ON respectively on the level what was sent
I am using a Arduino Mega2560 and progrmam it with the IDE from www.arduino.cc and program the uC via USB.
So there is a bootloader on it..is the bootloader turning on the LED13 ?
Does this might cause the problem? Even the Java is sending for 10sec. the uC is not doing what expect. with the break I have mentioned here it is working fine ..
Any idea ?
Always plugin the uC, wait at least 10 seconds and _THEN_ start the java program. I guess you know that, but maybe someone else could need that info. Also make sure no other program wants to send anything over your COM. close the Arduino IDE, although it shouldn't make any problems, but who knows.
You wrote:
>> Now here I am experiencing that LED13 goes ON and remains ON even
no data is sent ?
That is not correct and does not happen in my setup. maybe you chose the wrong board in your Arduino IDE? for example arduino mega 1280 instead of 2560 or something. if that is not the problem, try to restart your uC manually by pushing the reset button on your board at that time. but i guess that wouldn't help either.
LED 13 is connected to a strip of LEDs, too isn't it? So one color of one strip has to blink randomly, too. It has to be the blue color of the right strip, if you connected everything the way I wrote it in one comment, otherwise it has to be another color. but pin 13 has to be connected with a strip, because only pins 2 to 13 are PWM pins and that's exactly 12, just as we need it. Am i correct?
I guess you connected everything correctly because you say, it is working with your method explained. At least for one cycle.
Probably it is an issue caused by the operating system handling the COM ports. Windows 7 for example always checks the whole bunch of Com ports which takes up to 5 seconds everytime you try to change something with your serial. you should note that when you use the Arduion IDE and try to change the comport or the board.
data is being sent over the serial connection to checkout if that port is available (or something like that). That lets the microcontroller restart and blink randomly, which is no problem but should be mentioned. That could happen when the 'Looking for Com Ports' waiting screen appears or when you plugin your uC for the first time. Just wait a few seconds before activating the COM port in my program until the uC is setup correctly and waiting for data.
If all that won't help i have got another idea. we have to check out if it is a problem on your pc or on your uC. we could try it with boblight. for that we have to change the source code. we have to break down the problem to solve it. but we will solve it, I'm sure :-)
Check your hardware (pins 2-13), check your board settings in arduino IDE!
Thx
First of, thank you very much for a very nice instructable!
Unfortunately I too have the same problem that only blue light is showing from the pin 13 and that's it. Nothing else is happening even though I see that the Java app is sending data to the Mega.
Did you guys figure this out or is it still a work in progress?
Thanks for your time and I too hope that this problem can be solved!
http://db.tt/vguZrVVH
Everybody else who want to check out this program let me know how to improve it. This is actually my very first Python program ;-)
I had the same problem with pin 13 and it seems to be because of the serial communication but I don't know how to solve it.
boblight does not work for me at all.
I hope that after I get all my parts everything will work fine with this python program.
Great job!
I struggled a bit though to find and install all libraries that were necessary.
Is there a posibility to compile it to an executable? so I don't have to open it in python all the time.
Or you can start it from the comand line python yourscript.py
But I will post you an exe-file soon.
Regarding the functionality of boblight and ledtvlights original JAVA program, I am pretty sure it is because of the different Serial-Port-conections on the different Arduino boards.
Some are having the FT232 chip, some of them are having a ATMega8 with bootloader which needs an extra second before respectively is making an Auto SW Reset .. look here for some details
http://arduino.cc/en/Main/ArduinoBoardMega2560
I read many posts about this and found out that there is actually a new firmware supposed to correct this. I flashed it on my arduino using the FLIP utility from Atmel, but I'm not completely sure it changed sth. I mean the log showed that the update was successful but I'm not sure if it changed sth, the bootloader version that I have now is 1.2.0 and I don't know which is the original one.
It is tricky to reset the board and put it in DFU mode for the flash update but I managed to collect several pieces of information from different forums.
I tried again the JAVA application with no success. Your application works now just if I change the delay value in it to 0 vs 4 the default that you put.
I still need to receive the uln2003a ICs and then I will be able to fully test it with LEDs.
Your app is fine now, I managed to launch it directly so it's all right.
With boblight the problem comes because I don't quite understand how to change the config file for my needs, thus it gives me an error on launch that it cannot access the com port, although in the config file I modified it.
I can't wait to finish the whole thing, maybe then we can give the creator of this topic some info about some tweaks that need to be made in order for it to work.
I would like to have the JAVA app running as well or at least boblight but the only solution I find is to order a mega1280.
could this be the root cause in combination of the Auto-Reset when the controlling PC opens the com port ?
After Reset (Com port opening) it takes about 1s before the Arduino is ready to receive and control the PWM ...
I will update the whole tutorial in a few days to two weeks which will make it much easier. By the way this is much easier and gives you really good results:
http://ladyada.net/make/adalight/
I was wondering if anyone else has had such problems, or if it has something to do with windows7 dropping serial data. I'm using a FTDI FT232RL for the usb to serial.
How long should the strips be for a 22" screen?
I have never done anything like this before so what sites should I look at to get similar prices to what you did?
You need (2*10.8")+19.2" of strip. So about 40" which is 1m. Here you could buy it online in China without shipping costs. I guess it takes about 1-2 weeks to arrive and I have never had any trouble with this store.
http://www.dealextreme.com/p/waterproof-1-meter-4-5w-30-led-rgb-light-strip-dc-12v-16868
You could also buy it on eBay for about the same price I guess.
The other parts:
TLC5940 and ULN2003 - Electronic store nearby or eBay.
Arduino - Ebay (Fake from china works good as well) or Sparkfun (if you want it original, but more expensive).
http://bit.ly/nQLrz4 (arduino mega)
http://bit.ly/nhN9HI (ULN2003)
http://bit.ly/n8KYSy (LEDs)
A person in the comments of the LED page mention 3 parts where you can cut off, is that going to be a problem saying this requires 4 parts, should I consider getting a different one?
Also what type of power supply am I getting, I know 12v with at least 1amp but would it be one of these?
http://bit.ly/nEdEr1
And I'd just like to say that I really appreciate your help, especially since I am new to all of this and may be asking some silly questions :)
You would need more LEDs, I guess. So buy at least two of the 1m strips. For my 37" TV 2 meters of LED strips was perfect. And for a 46" tv it was still really good. So if you have a TV of this size or even bigger you would definitely need longer strips. You looked for waterproof strips which is absolutely not necassary. Look at this article:
http://goo.gl/EeoFc
It costs a little bit more but you get 5 Meters and could sell the rest on the internet and get at least 20$ for the rest so it's still cheaper. And these LEDs can be used for all kind of stuff. Maybe you want to build another one for a friend or something.
These LED strips can be cut every 3 LEDs, so every 10cm. But then you have to solder your own connections which may be a bit tricky. But every 50cm there are solder points on the strips where you just have to solder a cable to the strip and that is really easy.
Your power supply link doesn't work.
I would prefer a bigger power supply than 1A because you can use these power supplies for all kinds of projects and maybe you want to use it with the rest of your LED strip which is 3 meters of length and need more power. Also you have got some reserves and the supply doesn't get that hot.
I guess you come from Great Britain, because one of your links leaded me to a british homepage. but you can get these power supplies everywhere:
http://goo.gl/MUBqu
I am considering getting a 3 screen setup, so would you suggest using 6 strips, 2 on the top of each screen and non on the sides becuase of the positioning. (this would be half a meter on the top of each screen as they are only 22")
Can the arduino mega support 6 strips?
And can your program support 3 screens?
The resolution would be 5760 x 1080
I try change boblight config file. I can change all com port, channels pcs and other settings ok. But no light light up my arduino board. And tx/rx leds no blinking when i start boblighttd and after that getpixel progman. Both programs shows only black (black) Windows CMD -window.
Can you copy/paste or upload config file what works with your arduino code? Or explain can i change arduino code/or boblight config file right.
I am very thankfull if you can answer to me with this problem :) I can c/p some picture/video with my setup when i get that working, if that ok.
Uhmmm, I'm wondering if i could use 4 RGB strips with only 1 arduino and 1 power supply and using ULN2003 chip instead of transistor and resistors?
How many uln2003 chips i need?
Can you post more picture on how you wire those RGB strips into the chip?
Sorry if i ask too many questions, its because i have zero background about electricity and engineering..
Cheers, kevin..
These LED strips have got four wires. One is positive (12V) and the others just go into the ULN2003 output. So you can switch the 12V on by applying 5V to the ULN2003.
I really have no time at all, sorry!
Would 1 Arduino Mega with ATmega1280 chip will work properly??
Because i found its cheaper than ATmega 2560 chip..
What about the code? Do i need to configure specific code, or just plug and play it?
You only need two ULN2003A/L because each of them can switch up to seven channels. But we only need 6 per chip.
Connect pins 1-6 of the ULN chips to your PWM pins of your arduino (2-13). Pin 7 will not be used. Pin 8 must be connected with the other uln2003 chip pin 8. It's the ground pin. Connect it to your arduino ground and your power supply ground as well. then connect pins 10-16 of both chips with the LED strips (RGB). the rgb strips have got another connection, namely the common anode. connect all of them to the power supply positive pin.
I rewrote the source code of the arduino and java for the mega μ-Controller.
Here you go:
http://uploaded.to/file/9h8d5n1s
Check out the other comments for more info.