How to Paint with Light and Raspberry Pi

You can paint with light if you use a camera with large exposure times, while generating moving images with a Raspberry Pi (RBPi). Light painting is not new and traditionally images were hand-painted with a penlight. With the availability of cheap micro-controllers and addressable RGB LEDs, the idea of light painting has taken on a different meaning.

Since the images are large, producing them requires huge amounts of memory, something that RBPi has ample quantities of. Adafruit has Digital Addressable RGB LED Strips and connecting them to the Raspberry Pi is quite simple except that Raspberry Pi will not be able to supply the high currents that the LED strips demand, therefore, an external power supply will be required to power the strips.

Since the project will move about a lot, strong and reliable connectors will be required to interface between the Raspberry Pi and the LED strips. Connections from the GPIO of the RBPi are best taken via a 26-pin IDC cable and header. The LED strips are connected using two JST 4-pin plug and receptacle cables. The wires of the cables are soldered together in the proper sequence.

Since the RGB LED strip requires updating at very high speeds, this is addressed with a Serial Peripheral Interface or SPI bus. However, the GPIO libraries that RBPi uses with the “Wheezy” OS distribution are not fast enough. Therefore, Raspberry Pi needs a change of OS and must use “Occidentalis”, which is the Adafruit Raspberry Pi Education Linux distro, and includes the SPI support.

Occidentalis also has sshd that makes it easier to transfer images from a PC to the Raspberry Pi. sshd is the “secure shell” daemon server. It is like a secure version of telnet, allowing a user running the ssh client program on a local computer to connect to another (remote) computer running the sshd server, and logon to the remote computer. Unlike telnet, the communications are encrypted against network sniffers.

A Python Image module is used to convert the image transferred to the Raspberry Pi to an RGB format suitable for the LED display via the SPI devices. Instead of repeatedly processing each row or column of the image on the fly, the entire image is preprocessed into the hardware specific format suitable to the LED strip and stored in the memory of the RBPi as arrays. Refreshing the display is then only a matter of reading these arrays from the memory into the SPI port. More details of the hardware and software are available here.

The motion rig consists of a large PVC pipe bent into a ring on a hula loop. The LED strip is mounted on this and retained with zip ties. The ring assembly, batteries and the electronics is attached to the rear of a bicycle, which provides the motion. The entire arrangement including the bicycle must be painted matt black to be invisible in the photos.

For the power supply, 12V batteries have to be used, and a DC-to-DC converter is required for powering the LED strip and the electronics, all of which operate at 5V. The result of all this labor is limited only by your imagination.