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!

22 thoughts on “Adalight, Arduino, Boblight, Ubuntu and XBMC”

  1. 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?

  2. 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.

  3. 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.

  4. 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!

  5. Hey, nice tutorial man!

    I am planning to get a similar Setup and compile boblight on my xbmcbuntu installation.

    I am very interested in getting boblight to start when my computer starts and auto logs in to xbmc.

    Did you find a way to autostart it with system boot?

    from Germany,
    Hendrik

  6. I believe you need to add the boblight daemon to your rc.local file:

    sudo nano /etc/rc.local

    and add

    /usr/local/bin/boblightd -f

    I’m away from my machine at the moment but i’ll check and post back if my rc.local is any different to this…

  7. Hey Guys,

    just made my adalight, boblight, xbmc ambilight working yesterday…
    Now i am experimenting with the boblight settings to get them perfect.

    What do you guys advice for
    Speed
    auto Speed
    Interpolation
    Saturation
    Value
    Threshold
    ?

    Right now I have got

    Speed 51
    auto Speed 0
    Interpolation 0
    Saturation 1,80
    Value 2
    Threshold 20

    I noticed led`s often were still on with dark screen parts and turned blue… What do I have to change to make dark parts not being coloured blue on the led’s ?

    so far i am really happy with it just really wanna have a colourful but not plastic colorsetting for boblight.

  8. I’ve not personally experienced with the speed settings; the colour sections I adjusted as my blacks were kinda blue to start with… add this to the top of your boblight.conf file (if you don’t already have it):

    [color]
    name red
    rgb FF0000
    gamma 2.1
    adjust 0.12
    blacklevel 0.01

    [color]
    name green
    rgb 00FF00
    gamma 2.1
    adjust 0.12
    blacklevel 0.01

    [color]
    name blue
    rgb 0000FF
    gamma 2.2
    adjust 0.1
    blacklevel 0.01

  9. Hi. I do everything like you wrote. First problem i saw it was after type boblight-constant FF0000. Nothing happend:(. I have 100 WS2801 Led and only 25 light. When i connect Arduino 100 Led light up. On web i can’t see another tutorials for linux (only for Win or Raspberry). I can’t wait when it start working. Please help.

  10. I believe its the amps that you need to drive more than 50 LEDs; you may want to check with a multimeter whether the end of the strands in your setup are getting power; if not you’ll need to bridge the strands as per the diagram here: http://learn.adafruit.com/assets/1573

    Are you using the terminal to test the boblight configuration? could you paste your boblight.conf?

  11. I’m using the terminal because i have minimal debian. I think the power is enough because after i connect Arduino all LEDs light tree colors. I try few config. Last is (of course LEDS is 100 i my conf):

    [global]
    port 19333

    [device]
    name ambilight
    type momo
    output /dev/ttyACM0
    channels 300
    prefix FF
    interval 20000
    rate 115200
    debug off
    delayafteropen 1000000

    [color]
    name red
    rgb FF0000
    gamma 2.1
    adjust 0.12
    blacklevel 0.01

    [color]
    name green
    rgb 00FF00
    gamma 2.1
    adjust 0.12
    blacklevel 0.01

    [color]
    name blue
    rgb 0000FF
    gamma 2.2
    adjust 0.1
    blacklevel 0.01

    [light]
    name 001
    color red ambilight 1
    color green ambilight 2
    color blue ambilight 3
    hscan 0 10
    vscan 89 94

  12. try this boblight.conf:

    [global]
    port 19333

    [device]
    name ambilight
    type momo
    output /dev/ttyACM0
    channels 288
    prefix 41 64 61 00 5F 0A
    interval 20000
    rate 115200
    debug off
    delayafteropen 1000000

    [color]
    name red
    rgb FF0000
    gamma 1.0
    adjust 1.0
    blacklevel 0.0

    [color]
    name green
    rgb 00FF00
    gamma 1.0
    adjust 1.0
    blacklevel 0.0

    [color]
    name blue
    rgb 0000FF
    gamma 1.0
    adjust 1.0
    blacklevel 0.0

    [light]
    name Left1
    color red ambilight 1
    color green ambilight 2
    color blue ambilight 3
    hscan 0 10
    vscan 92 96

    [light]
    name Left2
    color red ambilight 4
    color green ambilight 5
    color blue ambilight 6
    hscan 0 10
    vscan 88 92

    [light]
    name Left3
    color red ambilight 7
    color green ambilight 8
    color blue ambilight 9
    hscan 0 10
    vscan 84 88

    [light]
    name Left4
    color red ambilight 10
    color green ambilight 11
    color blue ambilight 12
    hscan 0 10
    vscan 80 84

    [light]
    name Left5
    color red ambilight 13
    color green ambilight 14
    color blue ambilight 15
    hscan 0 10
    vscan 76 80

    [light]
    name Left6
    color red ambilight 16
    color green ambilight 17
    color blue ambilight 18
    hscan 0 10
    vscan 72 76

    [light]
    name Left7
    color red ambilight 19
    color green ambilight 20
    color blue ambilight 21
    hscan 0 10
    vscan 68 72

    [light]
    name Left8
    color red ambilight 22
    color green ambilight 23
    color blue ambilight 24
    hscan 0 10
    vscan 64 68

    [light]
    name Left9
    color red ambilight 25
    color green ambilight 26
    color blue ambilight 27
    hscan 0 10
    vscan 60 64

    [light]
    name Left10
    color red ambilight 28
    color green ambilight 29
    color blue ambilight 30
    hscan 0 10
    vscan 56 60

    [light]
    name Left11
    color red ambilight 31
    color green ambilight 32
    color blue ambilight 33
    hscan 0 10
    vscan 52 56

    [light]
    name Left12
    color red ambilight 34
    color green ambilight 35
    color blue ambilight 36
    hscan 0 10
    vscan 48 52

    [light]
    name Left13
    color red ambilight 37
    color green ambilight 38
    color blue ambilight 39
    hscan 0 10
    vscan 44 48

    [light]
    name Left14
    color red ambilight 40
    color green ambilight 41
    color blue ambilight 42
    hscan 0 10
    vscan 40 44

    [light]
    name Left15
    color red ambilight 43
    color green ambilight 44
    color blue ambilight 45
    hscan 0 10
    vscan 36 40

    [light]
    name Left16
    color red ambilight 46
    color green ambilight 47
    color blue ambilight 48
    hscan 0 10
    vscan 32 36

    [light]
    name Left17
    color red ambilight 49
    color green ambilight 50
    color blue ambilight 51
    hscan 0 10
    vscan 28 32

    [light]
    name Left18
    color red ambilight 52
    color green ambilight 53
    color blue ambilight 54
    hscan 0 10
    vscan 24 28

    [light]
    name Left19
    color red ambilight 55
    color green ambilight 56
    color blue ambilight 57
    hscan 0 10
    vscan 20 24

    [light]
    name Left20
    color red ambilight 58
    color green ambilight 59
    color blue ambilight 60
    hscan 0 10
    vscan 16 20

    [light]
    name Left21
    color red ambilight 61
    color green ambilight 62
    color blue ambilight 63
    hscan 0 10
    vscan 12 16

    [light]
    name Left22
    color red ambilight 64
    color green ambilight 65
    color blue ambilight 66
    hscan 0 10
    vscan 8 12

    [light]
    name Left23
    color red ambilight 67
    color green ambilight 68
    color blue ambilight 69
    hscan 0 10
    vscan 4 8

    [light]
    name Left24
    color red ambilight 70
    color green ambilight 71
    color blue ambilight 72
    hscan 0 10
    vscan 0 4

    [light]
    name Top1
    color red ambilight 73
    color green ambilight 74
    color blue ambilight 75
    hscan 4 8
    vscan 0 20

    [light]
    name Top2
    color red ambilight 76
    color green ambilight 77
    color blue ambilight 78
    hscan 8 12
    vscan 0 20

    [light]
    name Top3
    color red ambilight 79
    color green ambilight 80
    color blue ambilight 81
    hscan 12 16
    vscan 0 20

    [light]
    name Top4
    color red ambilight 82
    color green ambilight 83
    color blue ambilight 84
    hscan 16 20
    vscan 0 20

    [light]
    name Top5
    color red ambilight 85
    color green ambilight 86
    color blue ambilight 87
    hscan 20 24
    vscan 0 20

    [light]
    name Top6
    color red ambilight 88
    color green ambilight 89
    color blue ambilight 90
    hscan 24 28
    vscan 0 20

    [light]
    name Top7
    color red ambilight 91
    color green ambilight 92
    color blue ambilight 93
    hscan 28 32
    vscan 0 20

    [light]
    name Top8
    color red ambilight 94
    color green ambilight 95
    color blue ambilight 96
    hscan 32 36
    vscan 0 20

    [light]
    name Top9
    color red ambilight 97
    color green ambilight 98
    color blue ambilight 99
    hscan 36 40
    vscan 0 20

    [light]
    name Top10
    color red ambilight 100
    color green ambilight 101
    color blue ambilight 102
    hscan 40 44
    vscan 0 20

    [light]
    name Top11
    color red ambilight 103
    color green ambilight 104
    color blue ambilight 105
    hscan 44 48
    vscan 0 20

    [light]
    name Top12
    color red ambilight 106
    color green ambilight 107
    color blue ambilight 108
    hscan 48 52
    vscan 0 20

    [light]
    name Top13
    color red ambilight 109
    color green ambilight 110
    color blue ambilight 111
    hscan 52 56
    vscan 0 20

    [light]
    name Top14
    color red ambilight 112
    color green ambilight 113
    color blue ambilight 114
    hscan 56 60
    vscan 0 20

    [light]
    name Top15
    color red ambilight 115
    color green ambilight 116
    color blue ambilight 117
    hscan 60 64
    vscan 0 20

    [light]
    name Top16
    color red ambilight 118
    color green ambilight 119
    color blue ambilight 120
    hscan 64 68
    vscan 0 20

    [light]
    name Top17
    color red ambilight 121
    color green ambilight 122
    color blue ambilight 123
    hscan 68 72
    vscan 0 20

    [light]
    name Top18
    color red ambilight 124
    color green ambilight 125
    color blue ambilight 126
    hscan 72 76
    vscan 0 20

    [light]
    name Top19
    color red ambilight 127
    color green ambilight 128
    color blue ambilight 129
    hscan 76 80
    vscan 0 20

    [light]
    name Top20
    color red ambilight 130
    color green ambilight 131
    color blue ambilight 132
    hscan 80 84
    vscan 0 20

    [light]
    name Top21
    color red ambilight 133
    color green ambilight 134
    color blue ambilight 135
    hscan 84 88
    vscan 0 20

    [light]
    name Top22
    color red ambilight 136
    color green ambilight 137
    color blue ambilight 138
    hscan 88 92
    vscan 0 20

    [light]
    name Top23
    color red ambilight 139
    color green ambilight 140
    color blue ambilight 141
    hscan 92 96
    vscan 0 20

    [light]
    name Top24
    color red ambilight 142
    color green ambilight 143
    color blue ambilight 144
    hscan 96 100
    vscan 0 20

    [light]
    name Right1
    color red ambilight 145
    color green ambilight 146
    color blue ambilight 147
    hscan 90 100
    vscan 4 8

    [light]
    name Right2
    color red ambilight 148
    color green ambilight 149
    color blue ambilight 150
    hscan 90 100
    vscan 8 12

    [light]
    name Right3
    color red ambilight 151
    color green ambilight 152
    color blue ambilight 153
    hscan 90 100
    vscan 12 16

    [light]
    name Right4
    color red ambilight 154
    color green ambilight 155
    color blue ambilight 156
    hscan 90 100
    vscan 16 20

    [light]
    name Right5
    color red ambilight 157
    color green ambilight 158
    color blue ambilight 159
    hscan 90 100
    vscan 20 24

    [light]
    name Right6
    color red ambilight 160
    color green ambilight 161
    color blue ambilight 162
    hscan 90 100
    vscan 24 28

    [light]
    name Right7
    color red ambilight 163
    color green ambilight 164
    color blue ambilight 165
    hscan 90 100
    vscan 28 32

    [light]
    name Right8
    color red ambilight 166
    color green ambilight 167
    color blue ambilight 168
    hscan 90 100
    vscan 32 36

    [light]
    name Right9
    color red ambilight 169
    color green ambilight 170
    color blue ambilight 171
    hscan 90 100
    vscan 36 40

    [light]
    name Right10
    color red ambilight 172
    color green ambilight 173
    color blue ambilight 174
    hscan 90 100
    vscan 40 44

    [light]
    name Right11
    color red ambilight 175
    color green ambilight 176
    color blue ambilight 177
    hscan 90 100
    vscan 44 48

    [light]
    name Right12
    color red ambilight 178
    color green ambilight 179
    color blue ambilight 180
    hscan 90 100
    vscan 48 52

    [light]
    name Right13
    color red ambilight 181
    color green ambilight 182
    color blue ambilight 183
    hscan 90 100
    vscan 52 56

    [light]
    name Right14
    color red ambilight 184
    color green ambilight 185
    color blue ambilight 186
    hscan 90 100
    vscan 56 60

    [light]
    name Right15
    color red ambilight 187
    color green ambilight 188
    color blue ambilight 189
    hscan 90 100
    vscan 60 64

    [light]
    name Right16
    color red ambilight 190
    color green ambilight 191
    color blue ambilight 192
    hscan 90 100
    vscan 64 68

    [light]
    name Right17
    color red ambilight 193
    color green ambilight 194
    color blue ambilight 195
    hscan 90 100
    vscan 68 72

    [light]
    name Right18
    color red ambilight 196
    color green ambilight 197
    color blue ambilight 198
    hscan 90 100
    vscan 72 76

    [light]
    name Right19
    color red ambilight 199
    color green ambilight 200
    color blue ambilight 201
    hscan 90 100
    vscan 76 80

    [light]
    name Right20
    color red ambilight 202
    color green ambilight 203
    color blue ambilight 204
    hscan 90 100
    vscan 80 84

    [light]
    name Right21
    color red ambilight 205
    color green ambilight 206
    color blue ambilight 207
    hscan 90 100
    vscan 84 88

    [light]
    name Right22
    color red ambilight 208
    color green ambilight 209
    color blue ambilight 210
    hscan 90 100
    vscan 88 92

    [light]
    name Right23
    color red ambilight 211
    color green ambilight 212
    color blue ambilight 213
    hscan 90 100
    vscan 92 96

    [light]
    name Right24
    color red ambilight 214
    color green ambilight 215
    color blue ambilight 216
    hscan 90 100
    vscan 96 100

    [light]
    name Center1
    color red ambilight 217
    color green ambilight 218
    color blue ambilight 219
    hscan 92 96
    vscan 80 100

    [light]
    name Center2
    color red ambilight 220
    color green ambilight 221
    color blue ambilight 222
    hscan 88 92
    vscan 80 100

    [light]
    name Center3
    color red ambilight 223
    color green ambilight 224
    color blue ambilight 225
    hscan 84 88
    vscan 80 100

    [light]
    name Center4
    color red ambilight 226
    color green ambilight 227
    color blue ambilight 228
    hscan 80 84
    vscan 80 100

    [light]
    name Center5
    color red ambilight 229
    color green ambilight 230
    color blue ambilight 231
    hscan 76 80
    vscan 80 100

    [light]
    name Center6
    color red ambilight 232
    color green ambilight 233
    color blue ambilight 234
    hscan 72 76
    vscan 80 100

    [light]
    name Center7
    color red ambilight 235
    color green ambilight 236
    color blue ambilight 237
    hscan 68 72
    vscan 80 100

    [light]
    name Center8
    color red ambilight 238
    color green ambilight 239
    color blue ambilight 240
    hscan 64 68
    vscan 80 100

    [light]
    name Center9
    color red ambilight 241
    color green ambilight 242
    color blue ambilight 243
    hscan 60 64
    vscan 80 100

    [light]
    name Center10
    color red ambilight 244
    color green ambilight 245
    color blue ambilight 246
    hscan 56 60
    vscan 80 100

    [light]
    name Center11
    color red ambilight 247
    color green ambilight 248
    color blue ambilight 249
    hscan 52 56
    vscan 80 100

    [light]
    name Center12
    color red ambilight 250
    color green ambilight 251
    color blue ambilight 252
    hscan 48 52
    vscan 80 100

    [light]
    name Center13
    color red ambilight 253
    color green ambilight 254
    color blue ambilight 255
    hscan 44 48
    vscan 80 100

    [light]
    name Center14
    color red ambilight 256
    color green ambilight 257
    color blue ambilight 258
    hscan 40 44
    vscan 80 100

    [light]
    name Center15
    color red ambilight 259
    color green ambilight 260
    color blue ambilight 261
    hscan 36 40
    vscan 80 100

    [light]
    name Center16
    color red ambilight 262
    color green ambilight 263
    color blue ambilight 264
    hscan 32 36
    vscan 80 100

    [light]
    name Center17
    color red ambilight 265
    color green ambilight 266
    color blue ambilight 267
    hscan 28 32
    vscan 80 100

    [light]
    name Center18
    color red ambilight 268
    color green ambilight 269
    color blue ambilight 270
    hscan 24 28
    vscan 80 100

    [light]
    name Center19
    color red ambilight 271
    color green ambilight 272
    color blue ambilight 273
    hscan 20 24
    vscan 80 100

    [light]
    name Center20
    color red ambilight 274
    color green ambilight 275
    color blue ambilight 276
    hscan 16 20
    vscan 80 100

    [light]
    name Center21
    color red ambilight 277
    color green ambilight 278
    color blue ambilight 279
    hscan 12 16
    vscan 80 100

    [light]
    name Center22
    color red ambilight 280
    color green ambilight 281
    color blue ambilight 282
    hscan 8 12
    vscan 80 100

    [light]
    name Center23
    color red ambilight 283
    color green ambilight 284
    color blue ambilight 285
    hscan 4 8
    vscan 80 100

    [light]
    name Center24
    color red ambilight 286
    color green ambilight 287
    color blue ambilight 288
    hscan 0 4
    vscan 80 100

  13. Ok. I try this this evening. Could you write something about [light] section? I see that patern first time.

  14. It works:). Where is the secret? 4 last LEDS don’t light. And how config where ist the beginig? LEDs light on pleace where my Panasonic plasma have huge stand and i don’t need this. Tahnk you!

  15. Looking at your previous boblight.conf you had only initialised one LED (the light bits at the bottom of the conf). There is also an initialise string at the top which varies on the number of LEDs you are using.

    The LED incorrect position is entirely down to where it starts on your TV; you can try the boblight config creator app (windows only) to adjust the positioning and sequence of LEDs: http://www.mediafire.com/download.php?bks6dm0rp9pa8ky

  16. How adjust the positioning and sequence od LEDs? I use this software and want to firs led is the closest to arduino and its the bottom center. And next is clockwise. Now first light like the last:(. It’s so hard.

  17. Okay, it might be easier if you draw your setup… Make sure you include where the LEDs start running round your monitor/TV… Also count the number of LEDs on each edge… Post it back and I’ll create a closer boblight.conf for you

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>