ambilight icon indicating copy to clipboard operation
ambilight copied to clipboard

:izakaya_lantern: ambilight clone for your arduino and some WS2801s using boblight

This is a small project for creating an ambilight clone using an Arduino, a string of LEDs and WS2801s, and boblight. Installation instructions are provided for the Arduino Uno and Fedora 16, though they won't likely differ much for any Arduino/Unix-like combination.

Parts List

Installation

Make sure you have a libraries directory in the directory configured as your sketchbook in your arduino preferences.

SKETCHBOOK_PATH=$(grep ^sketchbook.path ~/.arduino/preferences.txt | cut -d = -f 2)
mkdir -p "$SKETCHBOOK_PATH/libraries"

Make sure you have the SPI library installed.

cd /tmp
git clone --depth 1 git://github.com/arduino/Arduino.git arduino
mv arduino/libraries/SPI "$SKETCHBOOK_PATH/libraries"
rm -rf arduino

Get the WS2801 library.

cd "$SKETCHBOOK_PATH/libraries"
git clone --depth 1 git://github.com/adafruit/Adafruit-WS2801-Library.git WS2801

Clone this project.

cd "$SKETCHBOOK_PATH"
git clone --depth 1 git://github.com/michaelficarra/ambilight.git ambilight

Download and install boblight.

cd /tmp
svn checkout http://boblight.googlecode.com/svn/trunk/ boblight
cd boblight
./configure && make && sudo make install

Install the boblight configuration file.

sudo cp "$SKETCHBOOK_PATH/ambilight/boblight.conf" /etc/

In the ardruino software, File -> sketchbook -> ambilight. Configure the dataPin, clockPin, stripLength, serialRate, and prefix values. Ctrl-u to compile and upload to your Arduino. Unplug your Arduino and attach the LED strip to your Arduino as in the following pictures.

connection to Arduino

connection to WS2801

WS2801 pins: from top to bottom: data, clock, ground, +5V

Configuration

There's a few configurable values in ambilight.ino.

  1. dataPin: the number of the Arduino pin connected to the WS2801 data pin
  2. clockPin: the number of the Arduino pin connected to the WS2801 clock pin
  3. stripLength: the number of WS2801-LED pairs, must be greater than zero
  4. serialRate: rate value from [device] section of /etc/boblight.conf
  5. prefix: prefix value from [device] section of /etc/boblight.conf

/etc/boblight.conf has to be configured with the regions (boblight calls them "lights") that are sampled for each individual LED. Below is a diagram of my configuration.

boblight.conf setup, with image of light positions

Running

Connect the arduino to USB. The first LED should be red, indicating it is waiting for a client.

Start the boblight daemon with boblightd. To detach it, instead run nohup boblightd &>/dev/null &. boblight-x11 connects to the boblightd daemon and sends the screen image data. I pass in some options with -o.

boblight-X11 -s 127.0.0.1:19333 -o saturation=1.7 -o value=0.5 -o threshold=60

Again, nohup may be used to detach it. If boblight-X11 fails to start with the error libboblight.so: cannot open shared object file, notice that /usr/local/lib must be in the LD_LIBRARY_PATH environment variable. Prefix the boblight-X11 invocation with LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib.