Ambilight system

Arduino project

Let's Begin

 

 

Description

Adalight is a do-it-yourself LED project kit that adds realtime ambient lighting effects to your computer monitor or home theater media PC. Inspired by the Ambilight feature of Philips’ LCD HDTVs, Adalight adds pop to TV shows, movies or games!

Pieces

A strand of 25 x 12mm LED pixels

5V 2A power adapter - this is a 100V-250V adapter

2.1mm female power jack Arduino

Wiring

The LED strand has a specific “input” and “output” end. The Arduino must connect to the “input” end! This is the smaller of the two plastic end connectors, the one with the triangular “arms”:

You can press wires directly into the plug connector. This works best with breadboarding jumper wires or solid-core (not stranded) copper wire. Only three wires will be used. The red wire does not connect to the Arduino. Three wires connect the Arduino UNO to the input end of the LED strand: the BLUE wire can connect to any Arduino GND pin. GREEN should connect to PIN 13 (SPI clock), and YELLOW to PIN 11 (SPI MOSI). The RED wire is NOT CONNECTED.

The exposed wire ends at the INPUT end will be carrying live current, so these should either be trimmed flush with the insulation, or better yet, covered with tape or heat-shrink tube. Don’t trim or insulate the wires at the opposite end…we need those! Power will be connected to the same red and blue wires at the output end of the strand. Data can only go one direction, but power can flow either way! The DC power jack has embossed “+” and “–” symbols on the top face. Connect the RED wire to + and the BLUE wire to –. Insert the wires into the “jaws” of the jack and cinch down the screws to hold the wires securely.

Installation

Download Arduino IDE

First, download the Arduino IDE (integrated development environment) from the Arduino web site. Select the version of the software for your computer type: Windows, Mac or Linux. Read the Getting Started page for an explanation of how to install the software on your computer.

Download Processing IDE

Next, download the Processing IDE from the Processing web site. The first section of the Getting Started page explains how to install the software.

If you’ve run the Arduino and/or Processing IDEs before, there will be corresponding “Arduino” and “Processing” folders inside your personal “Documents” folder (or “My Documents” in Windows). In that case, move the contents of the Arduino and Processing folders from the Adalight ZIP file into the corresponding document folders. If the Arduino and Processing folders don’t yet exist on your system, you can just copy these from the Adalight ZIP file to your Documents folder. The other files and folders in the ZIP file can be ignored. These are for advanced users and aren’t essential to its use.

Program the Arduino

Connect the Arduino board to your computer with a USB A-to-B cable. When connected for the first time, Windows users will prompted to install a driver. No driver is required for Mac or Linux. Launch the Arduino IDE. After a moment, you should see a simple blue and white window with some buttons. From the File menu, select Sketchbook, which should “roll over” to show LEDstream. Select this. From the Tools menu, select Board, then Arduino Uno (or whatever Arduino board type you’re using). From the Tools menu again, select Serial Port, and then the port corresponding to your Arduino board. Click the Upload button near the top-left of the window:

After the code is uploaded, if the LEDs are correctly wired up and the power supply is plugged in, the LEDs should all flash red, green, then blue for about a second each, then off. This is a startup diagnostic that tells you the LEDs and Arduino are working correctly, and are now awaiting data from the computer… Because the Arduino stores the program in non-volatile memory, you should only need to do this upload process once, not every time you want to use Adalight.

Proceed with this step only after the Arduino is programmed, the wiring is completed and the LEDs display the red-green-blue startup sequence. Launch the Processing IDE. After a moment, you should see a simple gray and white window that looks very similar to the Arduino IDE. From the File menu, select Sketchbook, which should “roll over” to show Adalight and Colorswirl. Select the latter first: Colorswirl. Click the Run button near the top-left of the window:

If the Arduino is the first or only serial device on the system, this should start a colorful rainbow of animation on the LEDs. If this is not what happens, then you’ll need to edit some code. Around line 26, look for this statement: myPort = new Serial(this, Serial.list()[0], 115200); We need to change how the code opens the serial connection to the Arduino. One route is just through trial and error: try Serial.list()[1], then Serial.list()[2], and so forth, re-starting the program each time to see if it works. For a more scientific approach, add one new line of code before running the sketch: println(Serial.list()); When run, this displays a list of all serial ports or devices. If you know which device or COM port corresponds to the Arduino, you can then change the original line to include this data. For example, it might now read: myPort = new Serial(this, "COM6", 115200); This will be different on every system, so we can’t just tell you what to put there. Another way to locate the port name: in the Arduino IDE, this is the port you selected in the Tools→Serial Port menu before programming the chip. Once you have Colorswirl working, make note of the change (if any), because the same change will need to be made in the Adalight code.

Moving ahead… From the File menu, select Sketchbook, then Adalight. If you changed the Colorswirl sketch to find the serial port, make that same change to the Adalight code. Now click the Run button. Though they’re in a jumbled mess on your desk right now, the LEDs should light up in colors resembling the perimeter of your screen. Move some windows around the edge — you should see the LEDs react to this. As it runs, the software performs a continual series of screen captures, averaging the pixels in blocks around the perimeter of the screen and issuing the resulting color data to the LEDs. You can hide the preview window and let the sketch continue working in the background. Being capture-based, it’s not tied to any one specific media player, and most anything you can put on your display — MPEG movies, YouTube, games and so forth — can benefit from the effect. It seems to work especially well with the outer space sequences in Cosmos…a bit ironic in that Carl Sagan’s “Spaceship of the Imagination” from this series featured a giant flat screen and mood lighting decades before Philips turned it into a commercial product!

If you plan to arrange the LEDs similarly to our examples — 25 pixels in a ring, 1 pixel gap at the bottom, with the first pixel starting just left of the gap — then nothing more needs to be changed in the software. If using a different layout, you’ll need to make adjustments in the code. You'll find extensive notes in the source code for making this (and other) changes.

Drop me a line


Copyright © 2016 Alberto Profile. |Alberto's website