DiY Light Painting wand using CircuitPython
So if you’re someone like me who loves to pursue more than one hobby, it feels incredible to make a project which help bring em together to compliment one another. Recently, I made one such project which complimented my hobby of making DiY electronics projects and Photography . On my last trip I was discussing with one of my friend the idea of doing Light Painting, though we couldn’t do it on trip, it stucked in the back of my head and finally decided to make something help do it.
So I made a CircuitPython powered Light Painting Photography wand. The good part about this project is it requires no external components so no soldering and is programmed in CircuitPython so means just a few lines of code is all you need ( 6 to be precise).
How Light Painting works?
Every camera has a shutter which you can control, i.e for how long you want shutter to stay open which in turns allows more light to come in. For light painting photography we open the shutter of camera for a longer duration typically (> 5 seconds) depending upon what you are trying to achieve. The good part is it can be done on both a DSLR and a mobile. You may need an additional application for your smart phone which allows you to manually control shutter speed such as SlowShutter and Moment. This technique is also sometimes called Long Exposures or Light Trail Photography because the light moves but shutter remains open so the sensor register it as a light trail and you can actually draw on air, such as down below:
Why use CircuitPython
So basically you can use anything to achieve this such as arduino and external LED. But I decided to go with circuitpython for following reasons:
1 - All the circuitpython compatible boards have an on-board RGB LED
YES! Gemma M0 has a DotStar LED, CircuitPlayground Express has 10x NeoPixels, so you don’t need to hook up any external LED by soldering or making circuit board. You can just program the on-board LED and since it’s RGB type you can output any color using it, good for light painting.
2 - CircuitPython is fairly simple, no compiling and uploading required. Easy to program, code lives on the board and can be edited using any IDE/terminal.
3- CircuitPython day is around the corner i.e 8th August 2019 and we at ILUG-D and Hardware Hackers Club are going to celebrate it so this project may serve as project inspiration for all the participants.
Let’s Make
To make this you need
1 - 1x CircuitPython compatible board. I’m using Gemma M0 and CircuitPlayground Express
2- A battery pack or Power Bank
3- USB Cable to connect the board to computer
The first step is to flash the board with latest stable circuitpython version. For that download the latest release binary from page hyperlinked in step 1. Press RESET on gemma m0 two times which will put it in bootlader mode. A drive will appear with the name GemmaBoot. Just drag the downloaded firmware file to the drive and the board will flash itself with latest version of circuitpython, 4.x in my case.
Also download the library bundle which matches your version from here . This contains all the circuitpython compatible libraries for sensors and other peripherals. Since boards like Gemma M0 have very less memory, you can add only the library which you wants saving the space.
Once the flashing is complete a new drive with name CIRCUITPY will appear on your system, make a new directory named “lib” inside root of CIRCUITPY and paste the Adafruit_dotstar library from library bundle which you downloaded above to lib directory, so now you can use this library to control on board dotstar LED.
Next Step is to download MU IDE which makes programming in circuitpython much easier, though you can use any IDE of your choice and just edit the code.py file in CIRCUITPY directory, save it to see your code running on the board.
Once all this is done, connect your board to the PC, open MU editor and paste the following code and click Save.
import board import adafruit_dotstar led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1) led.brightness = 1 while True: led[0] = (0,0,255)
The Code
Program is fairly simple and straightforward and if you’re already familiar with Python it will be a piece of cake.
line1: The first line we imported board library which will make all the features of board available for us to use.
line 2: Here we are importing the dotstar LED library which allows us to use that LED, the interpreter will load the library from /lib directory which we created in steps above
line 3: The next step might look intimidating to newbies but it’s nothing but initializing LED by telling interpreter we are using SCK(Serial Clock) and MOSI (Master Out Slave IN) lines to control the LED since dotstar LEDs work on two lines. and ‘1’ represent that this board only have 1 dotstar LED.
line 4: In this line we’re setting LED to full brightness 1 means full, 0 means lowest so .5 means 50%
line 5: SuperLoop (always true) which keeps running over and over
line 6: here we’re setting color of LED using 8-bit value (0-255) , RGB, Red(0), Green(0), and blue(255) so LED will set to blue color. Similarly for white we’ll do 255,255,255 and so on
Now unplug the board from computer and power it using a powerbank or battery holder ( 5V ). I’ve used a double sided table to attach the board to battery pack.
Setting up the Camera
To set the camera, decrease fstop to min number like 1/11 or 1/22. ISO to min value and open shutter for > 5 seconds. Experiment with different shutter speeds. For mobile decrease shutter speeds using app like Slow Shutter
Also make sure to set up camera on a tripod to avoid any shake while shutter is open. Now ask someone to press the shutter or put a timer. Paint in air using the wand you just made and enjoy the results.
Here are some of the shots I took
Let me know if you make one of this, tag me on Instagram @iAyanPahwa, and stay tuned for more such blogs. Toodles :)