# LED Lightbox

## Overview

When I was young, my family had a lightbox as part of our holiday decorations.&nbsp; No one could remember where it came from, probably a garage sale or something.&nbsp; It was extremely simple -- just six old-fashioned "blinker" Christmas tree lights behind a pane of textured acrylic that turned each light into a diamond pattern.&nbsp; The lights blinked on and off at random intervals.&nbsp; Each light was always the same color and there were only six of them, but something about it was... hypnotic.

One year it fell to the floor and broke.&nbsp; No big loss, everyone said, yet I'd never seen another one like it.&nbsp; Since then, I've always wanted to find another one.&nbsp; Years later, when I saw Adafruit's strings of 12mm LED pixels, I knew exactly what I wanted to make...

![](https://cdn-learn.adafruit.com/assets/assets/000/020/162/medium800/led_pixels_IMG_1398.jpg?1413229347)

Of course, this lightbox does much more than the original ever could.&nbsp; The RGB LEDs can create any color.&nbsp; And because it's all controlled by an Arduino, they can create different coordinated patterns instead of just blinking.&nbsp; Read on for descriptions of what the code already does, or you can edit the code to add your own new patterns.

&nbsp;

This project's code randomly displays many different patterns.&nbsp; The video below shows specially modified code to demonstrate all the patterns in the following order:

- Blinker bulbs, if old-fashioned blinkers could also fade to different colors, fade to new locations or flicker on/off.&nbsp; Random blinking is the default mode when no other effects are running.&nbsp; The video shows only a 2 second delay between each on/off effect; the unmodified code imposes a random delay.
- Tracers that chase across the field and bounce off the edges.&nbsp; The video first shows one tracer alone, then three simultaneously.
- Rapid scrolling of the entire field.&nbsp; The video shows this happening very suddenly, normally it doesn't follow so closely on the heels of a previous pattern.
- Conway's "Game of Life" (sorta), where each LED lights or fades based on the number of lit neighbors.
- A starfield, which lights all LEDs with a dim background color and random LEDs flare bright white.
- Blinkenleitz (for lack of a better name), where random LEDs flare brightly in random colors against a black background.
- A game of 2048, played randomly.&nbsp; Unfortunately for my ego, random play is nearly as successful as my own.
- Waves of random colors, spreading from a random point and consuming the entire field.
- Undulating/twinkling waves of colors, spreading across the entire field.&nbsp; The effect may remind you of looking up at the light through the surface of rippling water, or a flickering bed of coals in a dying fire, depending on how you like to spend your free time.

&nbsp;

## TL;DR

Blinking lights are pretty!

http://youtu.be/cTtNA68Kst0

## Skill Level

This project is very easy to assemble.&nbsp; Depending on what wire you use, you may not even need a soldering iron.&nbsp; In fact, the most important part is measuring carefully so everything looks straight -- more on that later!

# LED Lightbox

## Parts List

I didn't take separate pictures of each item I used to build the lightbox, but I'll list everything out below.

![](https://cdn-learn.adafruit.com/assets/assets/000/020/163/medium800/led_pixels_IMG_0410.jpg?1413229351)

###### _Yellow sticker reads: "Bad planning on your part does not constitute an automatic emergency on my part."_

&nbsp;

The most important piece is the case.&nbsp; It's what you'll see most, so it should look nice and you should be extra careful not to damage the exterior during construction.&nbsp; If you're handy enough, you can certainly build one yourself.&nbsp; I don't have a woodshop, so I bought a 12"x15" shadowbox from my local hobby store.&nbsp; Whatever you choose, be sure it puts several inches of distance between the glass and the back of the box.&nbsp; If the LEDs are too close the acrylic, their light won't be diffused enough.

Second most important is the patterned acrylic itself.&nbsp; I like the effect created by the diamond pattern, but don't let that stop you from finding something different!&nbsp; I purchased mine from&nbsp;[acrylite-shop.com](http://www.acrylite-shop.com/) because they laser cut it to the exact size needed.&nbsp; (As of this writing, they appear to offer a transparent honeycomb pattern that they didn't have before.&nbsp; It would probably look very nice.)

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/020/165/medium800/led_pixels_IMG_0502.jpg?1413229356)

Here you can see a few of the different patterns side-by-side.&nbsp; The big sheet at the bottom is the one I actually used.&nbsp; (Notice how the diamonds are quite a bit bigger in the bottom right compared to the top left?&nbsp; That's because the bottom right corner is about 0.3" further away from the LEDs than the top left.)&nbsp; Along the top row, left to right, the small samples are diamond patterned, honeycomb patterned and "stippled".&nbsp; (The small diamond and honeycomb samples also had an iridescent coating that doesn't show up in this photo; acrylite-shop.com calls it "Radiant").&nbsp; It only looks good in white light; I wouldn't suggest it for this project.)

![](https://cdn-learn.adafruit.com/assets/assets/000/020/164/medium800/led_pixels_IMG_0534.jpg?1413229356)

Full parts list:

- shadowbox
- patterned acrylic panel
- [Arduino Uno](https://www.adafruit.com/products/50)
- [12mm Diffused Flat RGB LED Pixels (strand of 25)](https://www.adafruit.com/products/738)
- [5V 2A switching power supply](https://www.adafruit.com/products/276)
- [2.1mm female DC power jack](https://www.adafruit.com/category/44)
- posterboard or foamboard (black)
- razor knife
- wire cutters
- heat shrink tubing OR electrical tape
- yardstick OR meterstick (depending on where you live)
- pencil
- hot glue gun or epoxy
- wire
- drill with 0.5" and 0.25" bits
- small phillips screwdriver
- calculator and notepad
- computer and USB cable

Pictured but not used:

- hammer (if frustration levels rise too high)

&nbsp;

# LED Lightbox

## Knives and Drills

The LEDs will be mounted in foamboard (or posterboard) just inside the back panel.&nbsp; If you're using a purchased shadowbox, it will come with a panel for mounting the display items (probably covered in cloth).&nbsp; Remove that panel and cut a piece of foamboard to replace it.

In my shadowbox, the Arduino is too big to stuff between the foamboard and the back panel, but it'll fit nicely along the side.&nbsp; So I cut a hole in the foamboard for it.

&nbsp;

The Arduino has some onboard LEDs of the boring non-RGB variety, which don't really fit with the theme of the project.&nbsp; Worse, some of its components are shiny and will reflect the other LEDs.&nbsp; So to hide it from view, I created a little "tent" out of some extra foamboard and glued it in place.

![led_pixels_IMG_0439.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/192/medium640/led_pixels_IMG_0439.jpg?1413229419)

![led_pixels_IMG_0441.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/193/medium640/led_pixels_IMG_0441.jpg?1413229419)

![led_pixels_IMG_0444.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/194/medium640/led_pixels_IMG_0444.jpg?1413230072)

Info: 

Use a calculator to determine the spacing you need and draw out the grid.&nbsp; For 25 pixels, you'll need 7 lines horizontally and vertically.&nbsp; The LEDs will go on every other intersection.

&nbsp;

Mark the points you're going to cut, otherwise you'll cut the wrong place when you're almost done.&nbsp; Having to start over will reduce your enthusiasm.&nbsp; (Trust me.)

&nbsp;

Cut the holes with your razor knife.&nbsp; I found it was easiest to cut square holes with the knife, then round them out by using a 0.5" drill bit as a hand tool (not in the drill).

![led_pixels_IMG_0418.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/195/medium640/led_pixels_IMG_0418.jpg?1413229429)

![led_pixels_IMG_0433.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/196/medium640/led_pixels_IMG_0433.jpg?1413229438)

![led_pixels_IMG_0434.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/197/medium640/led_pixels_IMG_0434.jpg?1413229440)

Info: 

Create a hole for the power jack by drilling from the inside.&nbsp; The 2.1mm jack is bigger near the posts than it is at the tip, so I used the drill to make the inside of the hole wider than the outside.

&nbsp;

Don't glue it in place yet -- wait until you have all the wires connected!

![led_pixels_IMG_0436.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/198/medium640/led_pixels_IMG_0436.jpg?1413229446)

![led_pixels_IMG_0524.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/199/medium640/led_pixels_IMG_0524.jpg?1413229454)

![led_pixels_IMG_0438.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/200/medium640/led_pixels_IMG_0438.jpg?1413229460)

# LED Lightbox

## Wiring and Code

The Arduino code for this project can be downloaded here [https://github.com/samclippinger/lightbox](https://github.com/samclippinger/lightbox)

Almost all of the tweakable values are set using #define commands near the top.&nbsp; For example, if you want to change the chance of a starfield effect appearing, look for STARFIELD\_CHANCE\_PERCENT.&nbsp; The comments should help explain what each value does.

# Wiring

Very little wiring is needed to make this project work.&nbsp; To start, the plugs on the ends of the LED strand are useless here, so go ahead and cut them off.

&nbsp;With only one of strand of LEDs, the "output" end isn't needed.&nbsp; I just folded the wires over and covered them in heatshrink.&nbsp; (I didn't want them to accidentally touch and short out some day.)&nbsp; If you want to make this project bigger and use more LEDs, you'll need to connect the strings and (if you have more than 50 LEDs) provide additional power mid-strand.

[For more details on wiring up these pixels, check out the main guide for them at https://learn.adafruit.com/12mm-led-pixels](../../../../12mm-led-pixels)

Danger: 

![](https://cdn-learn.adafruit.com/assets/assets/000/020/171/medium800/led_pixels_IMG_0435.jpg?1413229365)

On the "input" end of the strand, the "serial data" and "serial clock" lines will need to connect to the Arduino.&nbsp; The wires in the LED strand are multi-strand, which makes them nicely flexible but very difficult to mash into a breadboard (or an Arduino).&nbsp; I solved problem this by splicing them to a short piece of 20 gauge solid-core copper wire, which fits easily into an Arduino hole.&nbsp; After twisting the wires together, I dribbled a bit of solder on the connection to hold it.&nbsp; As a last step, I covered each junction with heatshrink so no one can see how bad I am at soldering...

&nbsp;The 5V and ground lines were already each split into two lines, but I decided I needed three: two to the Arduino and one to the power jack.&nbsp; Again, heatshrink makes it look very professional.

![](https://cdn-learn.adafruit.com/assets/assets/000/020/172/medium800/led_pixels_IMG_0432.jpg?1413229368)

On my LED strand:

- Red is the 5V line
- Blue is the ground line
- Yellow is "serial data"
- Green is "serial clock"

[For more details on wiring up these pixels, check out the main guide for them at https://learn.adafruit.com/12mm-led-pixels](../../../../12mm-led-pixels)

Danger: 

- Connect the **5V line** to both the positive post on the power jack and the **"Vin"** hole on the Arduino.
- Connect the **ground line** to the negative post on the power jack and the two **"GND"** holes on the Arduino.
- Connect the **"serial data input"** line to the Arduino's digital **pin 11**
- Connect the " **serial clock input"** line to the Arduino's digital **pin 13**

## Testing
Before you go any further, plug in the 5V power.&nbsp; Then connect the Arduino to your computer with a USB cable.&nbsp; (Don't plug in the USB first, or the Arduino will try to power the LEDs from the USB power, which could damage the Arduino.)

Use your computer to upload this project's code to the Arduino.&nbsp; If everything is wired correctly, you should see some of the LEDs light up and start to blink and/or fade between colors.&nbsp; The patterns won't be distinguishable while the LEDs are in a pile, but that's OK.&nbsp; If they light up, your wiring is correct.

![](https://cdn-learn.adafruit.com/assets/assets/000/020/173/medium800/led_pixels_IMG_0430.jpg?1413229368)

# LED Lightbox

## Final Assembly

Nearly done!

&nbsp;

The Arduino is going to remain unglued so it'll be easy to remove and upload new code.&nbsp; But since you don't want the connections to work free, it's not a bad idea to secure them with some hot glue.

![](https://cdn-learn.adafruit.com/assets/assets/000/020/267/medium800/led_pixels_IMG_0526.jpg?1413229976)

Next, glue the LEDs into the foamboard.&nbsp; Be sure to follow the same layout as in the picture below!&nbsp; If they're installed in a different order, the animations won't work correctly.

![](https://cdn-learn.adafruit.com/assets/assets/000/020/268/medium800/led_pixels_IMG_0446.jpg?1413229980)

Install the acrylic panel, glue the power jack in place and tuck the Arduino into its little cave.  
  
Lastly, close up the back panel, apply a sticker and you're done!

![led_pixels_IMG_0518.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/274/medium640/led_pixels_IMG_0518.jpg?1413230035)

![led_pixels_IMG_0524.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/275/medium640/led_pixels_IMG_0524.jpg?1413230042)

![led_pixels_IMG_0528.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/276/medium640/led_pixels_IMG_0528.jpg?1413230045)

![led_pixels_IMG_0532.jpg](https://cdn-learn.adafruit.com/assets/assets/000/020/277/medium640/led_pixels_IMG_0532.jpg?1413230048)

Hang it on the wall, put it on your desk or give it as a gift!&nbsp; Every time you have more than a minute to watch it, you'll end up hypnotized by it.


## Featured Products

### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### 12mm  Diffused Flat Digital RGB LED Pixels (Strand of 25)

[12mm  Diffused Flat Digital RGB LED Pixels (Strand of 25)](https://www.adafruit.com/product/738)
RGB Pixels are digitally-controllable lights you can set to any color, or animate. Each RGB LED and controller chip is molded into a 'dot' of silicone. The dots are weatherproof and rugged. There are four flanges molded in so that you can 'push' them into a 12mm drill hole in...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/738)
[Related Guides to the Product](https://learn.adafruit.com/products/738/guides)
### 5V 2A (2000mA) switching power supply - UL Listed

[5V 2A (2000mA) switching power supply - UL Listed](https://www.adafruit.com/product/276)
This is an FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but you can pick one...

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

## Related Guides

- [Arduino Lesson 11. LCD Displays - Part 1](https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1.md)
- [Arduino Lesson 7. Make an RGB LED Fader](https://learn.adafruit.com/adafruit-arduino-lesson-7-make-an-rgb-led-fader.md)
- [Multi-tasking the Arduino - Part 2](https://learn.adafruit.com/multi-tasking-the-arduino-part-2.md)
- [Digital Circuits 7: MCUs... how do they work?](https://learn.adafruit.com/mcus-how-do-they-work.md)
- [Arduino Ethernet + SD Card](https://learn.adafruit.com/arduino-ethernet-sd-card.md)
- [0.96" mini Color OLED](https://learn.adafruit.com/096-mini-color-oled.md)
- [Adafruit 2.8" TFT Touch Shield v2 - Capacitive or Resistive](https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2.md)
- [Adafruit Data Logger Shield](https://learn.adafruit.com/adafruit-data-logger-shield.md)
- [Line Following Zumo Robot Using Simulink](https://learn.adafruit.com/line-following-zumo-robot-programmed-with-simulink.md)
- [Adafruit INA219 Current Sensor Breakout](https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout.md)
- [Introducing Adafruit Trellis ](https://learn.adafruit.com/adafruit-trellis-diy-open-source-led-keypad.md)
- [Arduino Lesson 9. Sensing Light](https://learn.adafruit.com/adafruit-arduino-lesson-9-sensing-light.md)
- [RGB LED Matrix Basics](https://learn.adafruit.com/32x16-32x32-rgb-led-matrix.md)
- [Geofencing with the FONA 808 & Adafruit IO](https://learn.adafruit.com/geofencing-with-the-fona-808-and-adafruit-io.md)
- [Ladyada's Learn Arduino - Lesson #0](https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-0.md)
