Writing Text and Images in LEDs with the pyMCU

pymcu-led-pov-writingAlthough moving too slow at this point to be considered a “Persistence of Vision” device, the pyMCU with 10 LEDs attached makes for one of the simplest light painting bars that I’ve seen.  In addition to a small bill of materials, programming is fairly straightforward.  Everything is run off of a computer, so only one program is needed to both work work the image and run the LEDs (Python code and setup video included after the “read more”).

While simple, this device is limited in a few ways.  First of all, it’s black (red) and white.  Possibly a RGB LED strip could be used. like in this hack.  The linked hack uses Python to translate the picture into something that an Arduino can use.  The Arduino microprocessor then has it’s own code to execute the lighting instructions.

This brings up another obvious limitation of a pyMCU light painting setup; you’re tethered to a PC via the USB cable.  For tests this is fine, and might actually be advantageous in some situations, but it would be difficult to do light paintings in a natural setting while dragging a computer around.  On the other hand, I keep thinking back to my CNC light painting setup, and if the pyMCU/LED array was attached, some interesting effects could be done.

Here’s the video of the LED array being put together.  I was running it as a chaser at the time, but the physical setup is the same.  See this post for chaser code and a better explanation.  Also, make sure you don’t misplace a LED, I did that and kept thinking that pin 4 was malfunctioning!

Here’s the code so far for the “persistence of camera” setup.  When this is run, the LEDs will change in sequence.  By moving it across the lens when it’s open, you’ll be able to light paint whatever is on the image that you use.  The image needs to be 10 pixels high, and preferably black and white.

##########################################################
#uses 10 LEDs in sequence to display an image

import Image
import pymcu
mb = pymcu.mcuModule()

image_input = raw_input(“Image (with extension) to use? “)

image_work = Image.open(image_input).convert(“1″)

mb.pausems(1000)
for i in range(0, image_work.size[0]):
scanLine = “”
scanLight = []
#loop through y values (j) at X coordinate (i)
for j in range(0, image_work.size[1]):
pixel_value = image_work.getpixel((i,j))

#if pixel is black, turn on LED
if pixel_value != 0:
scanLine += “0″
else:
scanLine += “1″
scanLight.append(j + 1)

print scanLine, scanLight
mb.pinLow([1,2,3,4,5,6,7,8,9,10])
if len(scanLight) > 0:
mb.pinHigh(scanLight)
mb.pausems(30)

mb.pinLow([1,2,3,4,5,6,7,8,9,10])
##########################################################


Thanks to Richard Wardlow of pyMCU for helping me with this code.  You can buy one of these little boards off of their store if you’re interested in checking it out.  Also I modified the moster thing from an image off of Joystick Division.

  1. Servo Light Graffiti - Preliminary Results Drawing a Circle - pingback on January 27, 2013 at 8:16 pm
  2. free pyMCU giveaway! - pingback on May 5, 2013 at 3:29 pm
  3. Free pyMCU Contest Winner! - pingback on May 13, 2013 at 5:24 pm
  4. An Illustrated explanation of How Light Graffiti Works - pingback on June 9, 2013 at 9:26 am

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks: