# Adalight for Circuit Playground

## Overview

**PLEASE NOTE: we’re retiring this guide but keeping the information up for anyone who might learn from the ideas and code. It relies on an old version of Processing (at some point may stop working on new hardware), and recent operating systems are more restrictive about screen capture. It _can_ still run with some extra work, but there’s better alternatives now, Google for “DIY Ambilight clone” for others’ projects!**

![](https://cdn-learn.adafruit.com/assets/assets/000/038/361/medium800thumb/leds_cookery.jpg?1484199902)

One of my first projects with Adafruit was _[Adalight](../../../../adalight-diy-ambient-tv-lighting/overview),_ an ambient lighting effect for media PCs, similar to the _Ambilight_ feature&nbsp;of mid-2000s Philips TVs. Basically, matching what's on the screen to a set of background lights to make the display pop!

All the pieces of the Adalight project — a microcontroller, addressable “smart” LEDs and a USB connection — are present today on the diminutive Circuit Playground board. Why not replicate this classic project on today’s affordable hardware?

This small remake is no substitute for the gargantuan Adalight builds that some users have created…but for laptops or small all-in-one PCs, it can be a fun project for a board you may already be learning with. There’s **no soldering** and **no extra power supply** this time around!

Here’s what the original Adalight could do:

https://player.vimeo.com/video/30043456

For small screens, and only a few minute's time, we can have a pint-sized version&nbsp;easily working, just some software on your PC and on the Circuit Playground board. If you love it, you can always upgrade to the mega-AdaLight version!

# Adalight for Circuit Playground

## Download & Install

 **Three** pieces of software&nbsp;must be installed to follow this project:

# Arduino IDE

If you’ve used Circuit Playground before, the **Arduino** software is **already installed** on your system. If not, please read **[Circuit Playground Lesson #0](../../../../circuit-playground-lesson-number-0)** for guidance on downloading and installing the software and getting your computer talking to Circuit Playground.

Before continuing, you should know how to upload a sketch (such as the example “Blink” sketch) to the Circuit Playground board. Read through the getting-started guides (such as the one linked above) if this is unfamiliar territory.

# Processing IDE

Next, download the **Processing** IDE&nbsp;[from the Processing web site](http://processing.org/download/). _Processing_ is a programming language for Windows, Mac and Linux with audiovisual applications in mind. The first section of the&nbsp;[Getting Started page](http://processing.org/learning/gettingstarted/)&nbsp;explains how to install the software.

Danger: 

# Adalight ZIP

Finally,&nbsp;[visit the Adalight page on Github](https://github.com/adafruit/Adalight)&nbsp;and download the ZIP file, or simply use this link to download directly:

[Download Adalight ZIP File](https://github.com/adafruit/Adalight/archive/master.zip)
After uncompressing the ZIP file, you’ll need to move some files into place.

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).&nbsp;In that case, move the&nbsp;<u>contents</u>&nbsp;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 other projects&nbsp;and aren’t essential to its use.

![](https://cdn-learn.adafruit.com/assets/assets/000/038/352/medium800/leds_Adalight-CPlay-Folders.png?1484193996)

Danger: 

# Upload Code to Circuit Playground

Launch the Arduino IDE.&nbsp;From the&nbsp; **File** &nbsp;menu, select&nbsp; **Sketchbook** , which should “roll over” to show&nbsp; **LEDstream\_CircuitPlayground**. Select this.  
  
From the&nbsp; **Tools** &nbsp;menu, select&nbsp; **Board** , then&nbsp; **Adafruit Circuit Playground**.&nbsp;If this option is not present in the Board menu, the Circuit Playground software is not correctly installed. Please review the previously-mentiouned&nbsp;tutorials to get this started.  
  
From the&nbsp; **Tools** &nbsp;menu again, select&nbsp; **Serial Port** , and then the port corresponding to your Circuit Playground&nbsp;board.  
  
Click the&nbsp; **Upload** &nbsp;button near the top-left of the window:

![](https://cdn-learn.adafruit.com/assets/assets/000/038/353/medium800/leds_Adalight-CPlay-Upload.png?1484194516)

If all goes well, you should see a “ **Done Uploading** ” message in the Arduino window. You won’t see Circuit Playground doing anything yet, but it’s ready and waiting for other software on your computer to connect…

# Run the Processing Sketch

Launch the Processing IDE. After a moment, you should see a&nbsp;blue&nbsp;and white window that looks&nbsp;similar to the Arduino IDE, but darker.  
  
From the&nbsp; **File** &nbsp;menu, select&nbsp; **Sketchbook.** &nbsp;This pops out a new window, which you should be able to scroll through and find the “Adalight\_CircuitPlayground” sketch (if it’s not there, review the installation steps above), then open it.

You can _try_ running it just as-is, but it likely won’t work…you’ll either get a small preview window (that”s a promising start), or it might just completely crash if there are no serial devices attached.

**You need to edit the code first to point to the correct serial device number.** When the program first starts, it prints out the names&nbsp;of serial devices, starting from **#0**. If you **stop the program very quickly** , you can **scroll up in the console** to see this list… **count up from zero** until you find the **serial port corresponding to the Circuit Playground device** (it’ll be the same serial port name you selected in the Arduino IDE). Then run again. If it’s not working, check your counting and try again.

This will be different on every system, so we can’t just tell you what to put there.

![](https://cdn-learn.adafruit.com/assets/assets/000/038/354/medium800/leds_Adalight-CPlay-Run.png?1484195691)

When it works, you should see the NeoPixels on the Circuit Playground board light up.

# Adalight for Circuit Playground

## What It Does

With the **USB port at the bottom,** &nbsp;stick Circuit Playground to the back of your screen, facing the wall behind. Blue poster-tack or double-stick foam tape can work…or sometimes even regular clear sticky tape across the face of the board. But&nbsp; **DO NOT** &nbsp;stick Circuit Playground&nbsp;directly on the back of a **metal** -bodied device, like an aluminum MacBook, or you’ll get an electrical short…cover the back of the board or use a mounting method that leaves a little space between board and screen.

![](https://cdn-learn.adafruit.com/assets/assets/000/038/362/medium800/leds_CPlay-Mac-Back.jpg?1484202695)

Danger: 

The Processing sketch clones the contents of your screen and sends this data to the Circuit Playground, which then updates the LEDs. Try moving windows around, or play a movie or a game.

The Processing code captures screen shots just as fast as it can. In then divides this image into a 5x5 grid, and takes the averages of each of those squares…

Ten of those squares correspond to the ten NeoPixels on the Circuit Playground board. It’s not all one color…you can actually see motion reflected in the LEDs.

![leds_math1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/038/356/medium640/leds_math1.jpg?1484197026)

![leds_math2.png](https://cdn-learn.adafruit.com/assets/assets/000/038/357/medium640/leds_math2.png?1484197032)

![leds_math3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/038/358/medium640/leds_math3.jpg?1484197036)

 **The Processing code doesn’t work with all graphics cards and modes** …full-screen video, for example, may be accessing the graphics hardware directly and bypassing the normal frame buffer that Processing works with. (In one case, it works fine with full-screen movies on my NVIDIA-based iMac, but not my Intel Graphics-based MacBook Air…in the latter case, I have to keep the movie in a windowed mode, with the menu bar visible. Ah well.)

There are compatible third-party apps that may work better with full-screen video.&nbsp;[The original Adalight guide](../../../../adalight-diy-ambient-tv-lighting/advanced-topics#third-party-software-options) mentions a couple of options&nbsp;(Lightpack and Boblight) that may fare better in this regard, though they’ll require some initial set-up to define the pixel placement as described above.


## Featured Products

### Circuit Playground Classic

[Circuit Playground Classic](https://www.adafruit.com/product/3000)
Would you like to learn electronics, with an all-in-one board that has sensors and LEDs built in? **Circuit Playground** is here - and it's the best way to practice programming on real hardware with no soldering or sewing required!

This is the **Classic**...

In Stock
[Buy Now](https://www.adafruit.com/product/3000)
[Related Guides to the Product](https://learn.adafruit.com/products/3000/guides)

## Related Guides

- [Introducing Circuit Playground](https://learn.adafruit.com/introducing-circuit-playground.md)
- [Light Paintbrush with Circuit Playground](https://learn.adafruit.com/lightpaint-cplay.md)
- [Simple and Beautiful NeoPixel Holiday Lights](https://learn.adafruit.com/simple-beautiful-color-changing-light-strand.md)
- [Glowing Beehive Hairdo Wig](https://learn.adafruit.com/glowing-beehive-hairdo-wig.md)
- [Meditation Trainer](https://learn.adafruit.com/heart-rate-variability-sensor.md)
- [Circuit Playground Hourglass](https://learn.adafruit.com/circuit-playground-hourglass.md)
- [Glowing LED Team Badge for Pokemon Go](https://learn.adafruit.com/glowing-led-team-badge-for-pokemon-go.md)
- [Circuit Playground Combadge](https://learn.adafruit.com/circuit-playground-combadge.md)
- [Dotstar LED and Glass Pebble Floor](https://learn.adafruit.com/neopixel-and-glass-pebble-floor.md)
- [Circuit Playground Password Vault](https://learn.adafruit.com/circuit-playground-password-vault.md)
- [NeoAnim: Using Bitmaps to Animate NeoPixels on Circuit Playground](https://learn.adafruit.com/circuit-playground-neoanim-using-bitmaps-to-animate-neopixels.md)
- [Circuit Playground Analog Input](https://learn.adafruit.com/circuit-playground-analog-input.md)
- [Circuit Playground Fruit Drums](https://learn.adafruit.com/circuit-playground-fruit-drums.md)
- [Circuit Playground or Hallowing Jack-o'-Lantern](https://learn.adafruit.com/circuit-playground-jack-o-lantern.md)
- [Circuit Playground PZ-1: Pizza Box DJ Controller](https://learn.adafruit.com/circuit-playground-pizza-box-dj-controller.md)
- [Dear Diary Alarm](https://learn.adafruit.com/dear-diary-alarm.md)
