Adalight, Arduino, Boblight, Ubuntu and XBMC

After seeing my friend build his own Ambilight-esque LED backlight for his TV, and him kindly giving me a spare set of LEDs to construct my own (he bought too many sets); I’ve gotta say…

IT’S AWESOME:

If you’re looking to build your own; its not immensely straightforward but if you know your way around Arduino and the Ubuntu terminal, then this guide will help.

PREREQUISITES:
1). 12mm Diffused Thin Digital RGB LEDs from Adalight – http://www.adafruit.com/products/322
2). Arduino board (I have used an UNO R.2 board) – http://arduino.cc/en/Main/Buy
3). 5V 2A+ power supply (more on this later)
4). Ubuntu (or other linux distro)
5). XBMC 12.2 (will work on lower versions I think)

Step 1 – Build components
Follow this guide for construction of the LED array – http://learn.adafruit.com/adalight-diy-ambient-tv-lighting/overview
You only need to download the Arduino IDE; you don’t need Processing for this as another bit of software called Boblight will do the video processing for you.

Build and test the LEDs by uploading the Arduino sketch to your board; if its connected properly the LEDs will cycle through Red, Green and Blue once. If you’ve got this then continue…

Step 2 – Install Boblight
Boblight is a set of tools for driving external lights. It has far more usage than what we’re using it for but its less intensive on my system than using other image processors.

First off; open a terminal and install the prerequisites for Boblight:

sudo apt-get install libx11-dev libgl1-mesa-dev libxrender-dev libxext-dev portaudio19-dev libavcodec-dev libavformat-dev libswscale-dev libavdevice-dev libusb-1.0-0-dev

Next, ensure that G++ compiler is installed:

apt-get install g++

Once done you’ll need to install Subversion to get the Boblight codebase:

apt-get install subversion

Now your environment is all set; you can checkout Boblight and build it:

svn checkout http://boblight.googlecode.com/svn/trunk/ boblight-read-only

Once it’s downloaded, you should have a folder in your ‘Home’ directory called ‘boblight-read-only’; Change into this folder:

cd boblight-read-only/

Once in there issue the ./configure command:

./configure

Once it’s run; you can then get on with make and install Boblight:

make

and

sudo make install

Optional step: update ldconfig – I had an issue where one part of boblights install wasn’t referenced in another location (reported by boblight-X11: ERROR: libboblight.so: cannot open shared object file: No such file or directory); so I had to run

sudo ldconfig

to update my links.

Step 3: Boblight.conf file
Boblight needs a .conf file to initialise the lights; I’ve made a basic config file which you can download here

It needs to be placed in your /etc folder; unzip the file and copy it to the right location; you’ll need to be sudo to do this:

sudo cp 'PATH-TO-FILE' /etc/boblight.conf

This is setup for the basic 25 string of LEDs; if you have more, then you will need to edit the value listed under ‘Prefix’ to one of the following:

25 LEDs: 41 64 61 00 18 4D
50 LEDs: 41 64 61 00 31 64
75 LEDs: 41 64 61 00 63 66
100 LEDs: 41 64 61 00 63 36

Also; dependent on which port your Arduino board is connected to; you may have to modify the ‘output’ value; mine is set to /dev/ttyACM0

You can find out more about this in the Adalight forums: http://forums.adafruit.com/viewtopic.php?f=47&t=23972

Step 4: Test Boblight
If you’re still with me; fire up a new terminal and type:

sudo boblightd

If your config file is correct; this will start the Boblight daemon and you should see the LEDs cycle through RGB once more, and the terminal will state that boblight has successfully connected. Open a second terminal window and type:

boblight-constant FF0000

Your LEDs should now all be red! To kill this command simply press ctrl+C (Don’t shutdown the boblight terminal or you’ll lose the connection and will have to issue ‘sudo boblight’ again!

Step 5: install XBMC boblight addon
To install this add-on you must do so from the Add-on Manager from within XBMC by going to:

Settings
Add-ons
Get add-ons
XBMC.org Add-ons
Services
XBMC Boblight
Install

Once installed you should see a notification on screen that it has connected to boblight! Then choose a film, sit back in a dark room and marvel at your creation!

I’ll post a second guide to establishing the boblight daemon to run when XBMC is started once I figure it out!

11 responses to “Adalight, Arduino, Boblight, Ubuntu and XBMC”

  1. lizzir says:

    Its like a disco for your lounge…. I actually quite like it xx

  2. Tanner says:

    Awesome guide. I’ll be ordering parts this weekend and working on this. My first arduino project. Question: I have an extra raspberry pi, would that work for instead of the arduino uno? or is it worth it just to by the uno?

  3. bomski says:

    Yes you can substitute the Arduino for the Pi; it’s a bit more complicated but its a much neater solution (as you can install ubuntu and boblight on the Pi); check out https://dl.dropboxusercontent.com/u/6885567/PiBob/software.html

  4. Tanner says:

    I followed the setup from the adafruit site for 100 leds (for powering them), but when I upload the scetch to the uno, only the first strand of LEDs light up. I also installed the boblight software, and when i start boblightd, it only cycles thru the colors on the first strand of LEDs. And when I try to run the boblight constant command, nothing happens. any assistance would be appreciated.

  5. bomski says:

    it’s most probably a power-related problem; what’s your power supply? Adalight (makers of the LED strands) recommend a 10A supply; see: http://learn.adafruit.com/adalight-diy-ambient-tv-lighting/advanced-topics

    Also; when you initalise boblightd in the terminal; open a new terminal window and type ‘boblight-constant FF0000’; if its working all the LEDs will turn red…

  6. Tanner Postert says:

    It looks like there was a power issue, I’m ordering a replacement power supply, but I was able to get it powered properly. But the bigger issue was the prefix that you list for 100 LEDs, you list 100 LEDs: 41 64 61 00 63 66, but it is really 41 64 61 00 63 36. Those last 2 numbers are wrong. Also, a user would need to change their config to 300 channels instead of 75 channels (3 channels per LED, 1 for each color). You can also use the online tool to generate those sections for the config file. Thanks for your guide, it was a great helper. Right now I’m running into a minor issue where there is a split second delay in changing on xbmc, I also need to set the pixel off detection threshold higher so that I don’t have a bright red LED shooting out when there is an almost black edge on the screen. So far I am loving it. Thanks again.

  7. bomski says:

    Apologies; the prefix for 100 in my post is actually for 75; i’ve updated it… I’ve also experienced similar delay issues in very fast paced footage and boblight lagging (Jack Reacher cafe scene at beginning is a good example); I’m not sure there’s much to do (delaying the video by a 100 milliseconds or something allowing boblight to read ahead so to speak) but I’ve absolutely no idea how to do that (yet!)

    Glad you’re liking the setup; and for your corrections!

  8. Markus says:

    Hi,
    first of all that’s a great HowTo!

    i followed it step by step and everything worked well, but at the last point i get stuck.
    “sudo boblightd” starts as described LEDs in R, G , B are on
    check for constant light failed “boblight-constant FF0000” no light but i can see the connection to boblightd.
    if i start “sudo boblight-X11” i can see the established connection as well.

    when i start xbmc i get an error can’t conect to boblightd

    my boblight.conf is under /etc/
    [global]
    interface 127.0.0.1
    port 19333

    [device]
    name device1
    type momo
    output /dev/ttyACM0
    channels 150
    prefix 41 64 61 00 31 64
    interval 40000
    rate 500000
    debug off #turn this on to see what it’s doing with the serial port

    is a entry in rc.local neccessary?

    thanks for your help!

  9. bomski says:

    I believe your init.d needs modifying; there’s a pretty concise instruction to get it added to the init.d here: https://github.com/arvydas/boblight/wiki/Automatically-starting-boblightd-on-Linux

  10. jamieb says:

    Great tutorial! I moved over from windows and this helped loads.

    At the end you state when you find how to autorun the bob light daemon you’d post. Did you ever find this out?

    Thanks again Jamie

  11. jamieb says:

    Figured it out for anybody else needing to know i did the following…

    sudo nano /etc/rc.local

    and add this line at the end, but before the “exit 0”
    /usr/local/bin/boblightd -f

    Save / Exit

    Working in KodiBuntu 14.2

Leave a Reply

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