Home > Tech Project > ArduinoLight: First prototype

ArduinoLight: First prototype

To follow on from my last post, I’ve now stuck the LEDs and Arduino together in some sort of working fashion and have now started to play around programming it. Some of my results are below.

At the moment I’ve just cut out some cardboard to fit behind my monitor and taped the LEDs and Arduino to that. It’s a bit rough and ready but it serves it’s purpose.

At first I tried just sending some RGB commands down the USB using my own C++ code and then sending these along to the LEDs using LadyAda’s Arduino library to see what I could get out of the lights. This first attempt was just spamming the USB as fast as I could which resulted in some slightly odd, juddery colours appearing on the lights. It quickly became apparent that I needed some synchronisation between the PC and the Arduino and that I should probably up the baud rate of the connection.

Version 2 has the faster IO speed and now sends 25 RGB values and then waits for an acknowledgment signal from the Arduino. Now that it was communicating stably and at an acceptable speed I began my investigation into screen capture…

The video above shows my PC playing a clip from youtube of some colours swirling around which I’m capturing using DirectX9 and then mapping the colour values from on screen regions to each of the LEDs.

Because the capture is being done in hardware the load is reduced and spread quite nicely over the CPU and GPU meaning that it doesn’t really stress out your system (I found that the Processing project from the original AdaLight was straining my CPU at about 100%, my version is currently hitting about 10%).

You can probably see that the colours look a little jumpy and stutter when changing between the solid regions. This is because I’m currently displaying RGB values on the LEDs as soon as I receive them on the Arduino. The next step in this process is to implement some fades on the Arduino to smooth out these colour transitions. (any slightly odd colours you see are probably because my camera isn’t quite up to the task of recording this!)

Stay tuned for more!

Advertisements
  1. Jonathan
    January 6, 2012 at 11:26 pm

    Nice job! Is this project also available to download?
    I am also tried building my own ambilight clone with Ladyada’s adalight project, boblight and atmowin. But they all use too much cpu. If your clone could run on my not so powerfull PC, i’m very interessted.

    • January 7, 2012 at 2:11 pm

      Hi Jonathan,
      Thanks for commenting. Wow, you built all 3? That’s impressive! At the moment this project is not available for download, but if you’re interested I’ll put it up as soon as I can (I could do with doing a few tweaks so that anyone can use it, but I may be able to post it up before the end of the weekend).
      Just to give you an idea my PC has an Intel Core 2 Duo 2.4GHz CPU, 2Gb RAM and an 8800GTX graphics card and the program takes around 10% CPU and doesn’t seem to affect my performance so hopefully it’ll run well for you.

      • January 9, 2012 at 6:05 pm

        Hi Jonathan,

        As promised I’ve made a brief post with a download link to my Adalight application. Check it out on the home page.
        I hope it works ok for you.

  2. Diego
    March 25, 2012 at 11:21 pm

    Hi, I’ve just download your code and i have everything to build my own, just one question,
    is there any different on the code if I have a 50 RGB LEDS instead of 25?

    • March 27, 2012 at 7:28 am

      Hi Diego, the setup that I’ve coded has 3 real stages.
      1) The C# application. This does things like analysing the onscreen colours etc. It then sends these values to…
      2) The ArduinoCommsLib. This is a fairly simple library which just takes in an RGB value and an LED index and passes them, via the serial, to the Arduino.
      3) The Arduino sketch. This reads RGB values from the serial and displays them on the LEDs.
      Using 50 LEDs should be fairly simple to implement. Stage 2 (ArduinoCommsLib) will take in any index so you could easily pass in a range like 0-49 (or even 0-4999 if you wanted!) without having to make any changes.
      At the top of the Arduino sketch you should see a line saying “#define NUM_OF_PIXELS 25”. Simply change this to “#define NUM_OF_PIXELS 50” and the Arduino should be able to send commands to all 50 LEDs.
      The only remaining problem you have then is the C# app. Currently this is hard coded to only analyse 25 regions on the screen. I may make this a bit more customisable but in the mean time it will probably be quicker for you to write your own little app that talks to my ArduinoCommsLib library.
      I’ll have a look soon and see if I can make a build of something that will help you (e.g. I could release the source code for the screen capture library).

      I hope that helps. Let me know if you have any more questions.

  3. Diego
    April 10, 2012 at 11:27 am

    hey, thank u for the answer,
    well, I have a problem when I try to upload the: ArduinoTaskerLight.pde code file on the arduino uno
    when I upload the code it’s seems to be an error:
    PIC LINK:
    http://www.freeimagehosting.net/yziuc

    also have an error with the adalight code:
    PIC LINK:
    http://www.freeimagehosting.net/9go3u

    can u explain to me whats the problem, or how can I solve this?
    i will appreciate your help!!!
    And thanks again….

    • April 19, 2012 at 8:12 am

      Hi Diego,
      I believe the first problem that you’re having is that you don’t have the WS2801 library installed on your system. (The WS2801 is the little chip that helps control the LEDs). You can download the files you need for this library here: https://github.com/adafruit/Adafruit-WS2801-Library
      Once you’ve got these files, place them in your Arduino’s library folder. You can find some information on this process under the “Download” section on this page http://www.ladyada.net/products/pixel12mm/
      If you put these files in the right place you should then be able to declare “m_strip” as a WS2801 type without any errors.
      I’m not 100% sure about your second problem. It looks like something’s confusing the IDE and some of the standard keywords aren’t being recognised. It might be that the missing library is doing this or it could be something else. I’ll try to find out what the issue is and hopefully come back to you with an answer.
      If you manage to figure out the problem yourself I’d be very interested to hear what it was.

  4. Diego
    May 2, 2012 at 6:30 pm

    well, I have download the Adafruit_WS2801 BUT i still have the same error, I even put all the files on the same directory and even changing the file name to “WS2801” but every time I recive the same error “WS2801 does not name a type”
    can u please send me a zip file with your library already working (if its possible) to my mail??
    and tanks again….

    • May 6, 2012 at 9:21 am

      Whoops! I’ve done some more investigation and noticed some other things you’ll have to do to get the code working. Firstly, the WS2801 library that I had installed must have been an older or just a different version to the one on the adafruit site. I’m now using the latest version which is called “Adafruit_WS2801”. This means that you should actually have ‘#include “Adafruit_WS2801.h”‘ in your code instead of the ‘#include “WS2801.h”‘ that I had. It also means that you should define m_strip as an “Adafruit_WS2801” type, not just “WS2801”. I did this but then found that the adafruit library couldn’t find SPI.h. I did some experimenting but couldn’t get it to find the SPI header correctly, so I included “SPI.h” in my code and that seems to have fixed it.
      You don’t need to make these changes yourself, instead you can download my updated & fixed version from this post: https://taskercode.wordpress.com/2012/05/06/arduinolight-update/
      As long as you have the Adafruit library in your “Arduino\libraries\” directory, then this new code should work.

  5. Mario
    May 22, 2012 at 4:30 pm

    hi. I tried your project , fire.. rainbow are working but screen capture and wallpaper do not, task control panel do not display color in video capture and wallpaper, I tried also the original project processing 1.5.1 do not change led color but I’m able to see my monitor color. Do you have any advice ?
    thank you

  6. Mario
    May 22, 2012 at 5:04 pm

    hemm sort it out contrast and saturation were at 0 so was always white πŸ™‚ thank you anyway

    • May 22, 2012 at 6:11 pm

      hehe, glad you could sort it out Mario. I probably wouldn’t have even thought about the contrast or saturation options! Hope you enjoy playing with it, and feel free to leave any feedback.

  7. Mario
    May 23, 2012 at 3:27 pm

    first feedback, apparently is not working it display wrong color randomly. I mean if I try static color and I put green it display red , B is G and so on..sometimes green is green ..at least I’m able to address every led singularly. What can it be? arduino related? Led related? I tried in two pc and I had the same issue.

    • May 25, 2012 at 4:41 pm

      Hmm, it seems odd that the options like “Video Capture” or “Active Scene” would work correctly but “Static Colours” wouldn’t. The only real difference is the rate at which the colours are being sent to the Arduino (obviously video capture updates much more often than Static Colours for example). Are you using a Duemilanove and the same WS2801 library as my build?

  8. Mario
    May 27, 2012 at 8:27 am

    Every options display random color, static colors as video capture, the library is the one you linked but I’m using arduino uno r3, at the moment I’m on the original Adalight and it works. It seems a problem of comunication between arduino and the computer, I tried with windows 8 64 and win 7 32 and would tried also with an Acer eeepc but it seems that the software is too heavy for that Cpu/Gpu, the netbook was almost freezed. Another thing I see is that on my main computer with a strong Cpu but an old Gpu (ati 3450) the movie were sluggish but could be windows 8 64 related. Either way the colors were were wrong so I give up. Another thing sometimes the color were correct, usually Fire effect start correcly but in 10/20 sec developed in a bluish/violet Fire. So the correct I think was just a random that match. With I’m able to address single led I was meaning that I can can change a single led color but it display the color he want.

    • May 28, 2012 at 7:13 am

      Hi Mario, I’ve done a bit of reading up on the Uno board and the first thing that jumped out at me was that “The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.” (http://arduino.cc/en/Main/ArduinoBoardUno). This would suggest to me that the serial comms between the PC and the board is where the error is occurring. I don’t think I’ve put any real synchronisation into the IO code so it might be a little sensitive to different transmissions. If I were you I’d try to get back to basics and check that the Uno board is receiving and interpreting the USB signals as expected. In the mean time I’ll add “making USB comms more robust” to my changes list!

  9. Mario
    May 30, 2012 at 7:43 am

    hi, I think I’m gonna buy arduino 2009 to see how it goes and save Uno per other project

    • May 30, 2012 at 8:32 am

      Ok, well I’d be interested to hear how it goes. Hopefully the Duemilanove should work for you without much work.

  1. January 9, 2012 at 6:04 pm

Tell me what you think!

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: