After watching several videos and seeing numerous articles about light painting, I decided to give it a try. Light painting involves using a camera with a very long exposure time to capture a small light source. This allows for a single of light to become strung out to a long streak in a single image.
But what if someone wants to create a more detailed picture or use many different colors? This is how I came up with the idea to build a 2-axis CNC machine that has a single RGB LED that can change color and “paint” an image.
This project would require four main components to work: a 2-axis CNC machine, RGB LED, SD card, and a camera that is capable of taking long-exposure shots. First, the Arduino Mega would read the SD card and find a bitmap to print.
Then, it would go across horizontally and light up the corresponding LEDs while also moving down a row each time the image’s width is exceeded. Last, it will wait a bit and then search for the next bitmap, finally stopping whenever there aren’t any more images to create.
Constructing the RigDue to my experience designing and building CNC machine, this step wasn’t too difficult. I wanted to make something modular that could also be expanded for other projects, so I settled on a simple design that uses two timing belts attached to crossbars that move along parallel aluminum extrusions.
This lets the length of each axis be very customizable. The ends of the X-axis have 3D-printed endcaps on them, one of which has a mount for the X-axis stepper motor and bearing.
I chose the bitmap file format due to its simplicity and how easily it’s able to be read. Based on the file format, there are a few important addresses in the file itself that must be read. These are 0x12 (width), 0x16 (height), 0x1C (color depth), 0xA (location of pixel data), and finally 0x36 (where the pixel data usually is).
The data is read in chunks of either two or four bytes (16 or 32 bits), which also advances the pointer to the next address. The read function goes through and grabs all of the important data, including offsets and sizes. Then it goes through and reads each pixel, row by row.
Preparing the ImagesSince most cameras are limited to a maximum of 30 seconds of exposure time, there is a limit of about 288 total pixels that can be displayed in that amount of time. This equates to about an 18 x 16 image. To make my images, I loaded up gimp and began to create very simple pixel art. These included a Pokéball, heart, and a jumping Mario. Then I placed these three images into a directory called “bitmaps” in the root directory of the SD card. The program reads all of the images from this folder.
Painting ProgramSince stepper motors have no internal positioning feedback system, their positions must be tracked by software. The program I wrote keeps track of the LED’s position with a grid system to allow for easy scaling. When the Arduino Mega starts up, the stepper positions are set to 0, 0 and then the first image is found and read. Then, the LED blinks five times to let the photographer know it is almost time to start capturing. The bitmap is read by first looping through each row, and within each row, each column is read. By knowing the current row and column, the stepper motors can be moved to those same positions. At each position, the LED is changed to the color of that corresponding pixel.
(re)-Creating an ImageAfter inserting the SD card and plugging in a 12v power source for the motors, it was time to turn on the machine. On my camera, I set it for a 20-second exposure time, an aperture of F36, ISO of 100, and an exposure compensation of -5 stops to minimize ghosting effects. The first image drawn was a pokeball, seen here:
Although it is a little bit blurry, the shape can still be clearly seen. Then it created a heart bitmap:
Because this image was only 9 by 9 pixels, each individual pixel is a lot less defined. Lastly, I painted a picture of Mario jumping:
This picture has heavy ghosting, mainly due to the abundance of brightly colored pixels.
Future Ideas for ImprovementsThe light paintings I created turned out much better than I had initially thought they would, but there is still room for improvements. The main thing I would like to do is reduce the amount of blur by having the LED move while darkened and then only light up when still. This technique would greatly improve the clarity of the recreated images.
Comments