The best tools to make your project dreams come true

Login or Signup


Light Paintbrush with Circuit Playground

By Adafruit Industries

Courtesy of Adafruit

Guide by John Park

Overview

Light Paintbrush with Circuit Playground

 

Painting with Light

Streaks of colorful light, suspended in midair -- ever since people began to capture images on film we have had a fascination with light painting and light drawing. By simply moving a light source in front of an open shutter, motion over time could be captured on camera.

We have a rich history of light painting projects here at Adafruit, as well. Check out some of these excellent projects for incredible effects that involve persistence of vision images painted with light, and even thermal heat map painting.

Light Paintbrush with Circuit Playground

A Circuit Playground and a camera or smartphone capable of taking long exposure photos is enough to get started. By using the on-board accelerometer, you'll be able to change colors by rotating the Circuit Playground. As an added touch, you can use a potentiometer to easily adjust the brightness of the NeoPixels.

Code the Light Paintbrush

Before you get started, make sure you've been through the basic tutorials on using the Circuit Playground. You'll need to have installed the Arduino IDE, added the Circuit Playground board to Arduino, and added the Circuit Playground library. This excellent guide, Introducing Circuit Playground and Circuit Playground lesson #0 will show you how to do all of that and get you going in no time!

Light Paintbrush with Circuit Playground

Plug your Circuit Playground into your computer now using a USB cable, and launch the Arduino IDE. Double check that you've selected the board and port as in the Lesson #0 tutorial and are ready to upload code.

The code for the Light Paintbrush has two jobs:

  • Read the on-board accelerometer to determine which color to set the NeoPixels
  • Read the potentiometer connected to pin #10 to set the NeoPixel brightness
Copy Code
// ---------------------------------------------------------------------------
//Circuit Playground Light Paintbrush
// John Park
// for Adafruit Industries
//
// Use the Circuit Playground as a long exposure photography light paintbrush
// tilt to change color
// adjust brightness with the 10k potentiometer
//
/* X
* __
* / \
* Y | | -Y
* \__/
*
* -X
*/
//
// MIT license, check LICENSE for more information
//
//
// ---------------------------------------------------------------------------

#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
#include <SPI.h>

int sensorPin = A10;
int sensorValue = 0;
int brightVal = (20);

int X;
int Y;

int red = 0;
int green = 255;
int blue = 0;

void setup() {
CircuitPlayground.begin();
CircuitPlayground.clearPixels();
CircuitPlayground.setBrightness(brightVal);
}

void loop() {
sensorValue = analogRead(sensorPin);
brightVal = map(sensorValue, 0, 1023, 0, 225);

X = CircuitPlayground.motionX();
Y = CircuitPlayground.motionY();

if ( (X>=1) && (Y<1) ) { // x, -y = GREEN
red = 0 ;
green = 255;
blue = 0;
}
else if ( (X <1 ) && (Y<1) ){ //-x, -y = BLUE
red = 0;
green = 0;
blue = 255;
}
else if ( (X >=1) && (Y>=1) ){ // x, y = RED
red = 255;
green = 0;
blue = 0;
}
else if ( (X <1) && (Y>=1) ){ //-x, y = YELLOW
red = 255;
green = 255;
blue = 0;
}

for (int i=0; i<10; i) {
CircuitPlayground.setBrightness(brightVal);
CircuitPlayground.strip.setPixelColor(i, red, green, blue);
}
CircuitPlayground.strip.show();
}

Download the Code

You can press the button below to download the code. Unzip and move the directory CircuitPlaygroundLightPaintbrush to your Arduino sketch directory, then open it in the Arduino IDE and upload it to your Circuit Playground.

CircuitPlaygroundLightPaintbrush.zip

Next you'll assemble the Light Paintbrush.

Assemble the Light Paintbrush

Light Paintbrush with Circuit Playground

With the software loaded onto the Circuit Playground, your Light Paintbrush will need power and one additional sensor -- a potentiometer -- to control brightness. You'll use the battery holder as both power supply and handle for your Light Paintbrush. This is expedient, inexpensive, and a great example of form following function. You could build a nice enclosure for the project if you like, but the Light Paintbrush works well without one.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

The first build step is to attach leads to the potentiometer. The potentiometer uses three connections to the Circuit Playground -- ground, signal, and voltage. The ground and voltage are references for the varying resistance of the middle signal leg as the knob is turned. The Circuit Playground reads these changes as analog values from 0 to 1023, which are then remapped to NeoPixel brightness values in the software.

Cut one clip end off of each alligator clip lead, and strip away a bit of insulation to expose the wire. Tin the potentiometer legs with solder, tin the wires, and then solder the wires to the legs in the order shown here.

Light Paintbrush with Circuit Playground

Then, clip the leads to the pads on the Circuit Playground:

  • black to GND
  • yellow to #10 
  • red to 3.3V

Light Paintbrush with Circuit Playground

Next, use a small piece of foam double-stick tape to connect the battery case to the back of the Circuit Playground.

Light Paintbrush with Circuit Playground

Finally, use some foam tape to attach the potentiometer to the battery case.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

 

That's it, your Light Paintbrush is complete!

Turn it on and try tilting the brush to change colors, and adjust brightness with the knob.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Now comes the artistic part -- time to make some light paintings!

Paint with Light

Light Paintbrush with Circuit Playground

Now that you've built it , in order to paint with your Light Paintbrush you'll need a dark place and a camera or smartphone with "bulb" or long exposure mode.

On a camera, look for a "B" on the dial or check the far end of the shutter values. Bulb may require a held shutter, so it can be convenient to use a shutter in the 10-to-30 second range (notated as 10", 20", 30" and so on), or a remote trigger.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

For smartphones there are many apps available -- just search for "long exposure" or "light trails" in the app store of your choice.

Light Paintbrush with Circuit Playground

Now, head to a darkened room or outdoors at night. Set your camera or smartphone on a table or tripod, put it in long exposure mode with a small aperture to keep the scene fairly dark, and press the shutter.

Turn on your Circuit Playground Light Paintbrush, set the brightness knob to a medium setting, and move the Light Paintbrush in some circles and arcs. When you're done, press the camera shutter again and check your photo.

It may take some tuning to get the brightness and focus just right -- it's very helpful to have an assistant -- but once you do you'll see beautiful streaks of light with colors changing depending on the rotation arc of your arm or how you twist your wrist.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

This image was a single streak during a five second exposure.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

For these jellyfish-like images, the brightness knob was twisted on and off while moving and twisting the brush.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Less can be more.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

More can also be more.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Here I illuminated my face briefly as well by pointing the Light Paintbrush at myself.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

An external flash (or bright light turned on and off briefly) can help add your subject to the photograph without blurring.

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Light Paintbrush with Circuit Playground

Enjoy creating art with your Circuit Playground Light Paintbrush!

Key Parts and Components

Add all Digi-Key Parts to Cart
  • 1528-1640-ND