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…
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.
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:
Once in there issue the ./configure command:
Once it’s run; you can then get on with make and install Boblight:
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
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:
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:
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:
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!