LED Light Painting
A project to make light paintings using an LED strip and an Arduino. The idea for this project came mainly from the LightScythe, but the implementation is quite different!
Here are the major components if you would like to build your own:
All of the parts together now!
Here is a rough schematic for the circuit. I used Fritzing to make the diagram, and I’m still figuring it out, so there is room for improvement!
Warning! This code is a mess, but if you are looking for the gist of how the firmware works, it might be interesting.
- First bitmaps are loaded onto the microSD card and the card is put into the micro SD shield.
- When the battery is plugged in the Arduino and the LCD Screen power on.
- The first button is used to cycle through the pictures. The pictures are displayed on the LCD along with relevant info.
- The second button is used to write the bitmaps to the LED strip in the correct order to make the light painting.
- As the LEDs are written with the bitmap pixels, I walk along with the LED strip while taking a long exposure picture with my camera.
I use a matlab script to prepare the bitmaps, which is way overkill, but I like being able to plot the results!
First the image is resized. Because the LED strip has 64 LEDs, any picture that is displayed needs to be 64 pixels tall. The image can be any width.
After being resized, the picture is rotated 90°. The reason for doing this is that bitmap data is stored line by line horizontally. When making the light painting, however, I need to display the image line by line vertically. Rotating the picture before hand makes this easier.
Generating 7-Bit Color:
Each of the 64 LEDs is made with a red, blue, and green LED. The strip has built in 7-bit Pulse-Width Modulation to generate additional colors. 7 bits = 128 levels for each LED. 128^3 = 2 million colors! Sweet!
The original LED strip I used with this project had a different chip, that only allowed each LED to have an on/off state, which meant only 8 colors. With only 8 colors to work with, I had to get creative when down-converting full-color images. Here’s a shot I took of the old LED strip, where I used dithering to bring the picture down to only 8 colors:
When using PWM with LEDs, it is important to use gamma correction. This is necessary because there is a non-linear relationship between luminescence and brightness. Check out this app-note from Maxim-IC for more details.
Basically the color values need to be corrected with a gamma of 2.5. Here is an image without gamma correction:
As you can see, the colors are much less faded in the gamma-corrected image.
The only downside to doing gamma correction is that you can loose a lot of data at the low-end(darker pixels), but it’s usually not too noticeable.
It’s possible to have the Arduino do the gamma-correction, but it would require a lot more processing power. I gamma-correct the images before hand on a computer to get around this.
I originally had just 2 LEDs to display the status of the Arduino, so I decided to get a little fancy and include an LCD screen. It works much better than expected! It shares the SPI interface with the microSD Shield, so they need to take turns.
The screen is used to display:
- The name of the Bitmap file
- The width of the Bitmap file in pixels
- The amount of time it will take to write the whole image to the LED strip
- The maximum instantaneous current that the LED strip will need to display the picture.
- The current battery level.
- A preview of the picture.
Writing text and pictures to the screen was easy using the Adafruit tutorial and library.
Note: I store a non-gamma-corrected image on the microSD card as well as the gamma-corrected version. This is so that I can display the non-gamma-corrected version to the LCD and the gamma-corrected version to the LED strip without having to do any gamma correction calculations in the Arduino.
Scott-Bot.com by Scott-Bot is licensed under a Creative Commons Attribution 4.0 International License.