Contributors

From Pixels to NeoPixels

Lighting up NeoPixels on the Circuit Playground is fun and easy. But creating animation patterns with specific color, timing, and position can be difficult. Not any more! Using this technique and a small Python script, you can use a tiny bitmap image as a powerful control for making complex NeoPixel animations on your Circuit Playground.

Developed by our own Phil Burgess, this method has a lot in common with traditional hand-drawn animation timing charts and exposure sheets (also called dope sheets) in that a set of rows and columns are used to indicate an object's attributes over time.

Animation spreadsheets made leap from traditional animation to CG animation, and versions of it are still in use today in feature animation studio software such as Autodesk Maya and Pixar's in-house system, Presto.

In this example of animating a ball bounce in Maya, note the dope sheet interface where the translation, rotation, and scale values of the ball are the attributes being indicated on the vertical chart axis, and the time in frames are the horizontal axis. This is very similar to our bitmap-to-NeoPixel animaiton system.

In this case, rows indicate each of the ten NeoPixels of the Circuit Playground, and columns represent frames of animation in time. The color of a particular cell in the grid represents what color to display that NeoPixel at that frame in time.

Here's an example: This is a one second loop of animation divided into 24 frames per second (24 FPS) which is the standard for traditional film and animation. In the image above, the ten NeoPixels (numbered 0-9) will each be lit green for one frame of time until NeoPixel 9 is lit, which then stays lit for the rest of the animation loop.

Coding the Circuit Playground

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.

Plug your Circuit Playground into your computer now, 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.

Download the NeoAnim.zip Arduino sketch, then unzip it, and place the NeoAnim directory in your Arduino sketch directory.

The directory contains the NeoAnim.ino Arduino sketch, a 24x10 pixel neoAnim.png bitmap file, and the neoAnim.h header file that was created with the convert.py Python script we'll look at in a few steps.

Download the linked code from the button above, and then unzip the directory. Within the unzipped directory you'll find two directories: CircuitPlaygroundMakeBelieve, which you can move to your Arduino sketch directory (we won't use it for this guide, but it is useful if you want to build reactive props as shown in this guide), and the Extras directory, which you can place inside your NeoAnim directory you previously downloaded.

You can test the NeoAnim Arduino sketch by opening it in Arduino, and uploading it to your Circuit Playground. It should play a one second loop of a green pixel moving from upper left to upper right counterclockwise.

Now, you can adjust the animation. Open the neoAnim.png file in an image editor, such as Preview on OSX or MS Paint on Windows, or GIMP on Linux, and make some changes, such as the color of the non-black pixels. Save the file (it's OK to overwrite, you can redownload the original here).

In order to convert the new version of neoAnim.png to the neoAnim.h file, you'll need to follow these steps:

This file is referenced when Arduino re-compiles your NeoAnim.ino sketch, so to test it out, simply re-upload the code to your Circuit Playground. You've just animated your own NeoPixel animation using an exposure sheet style bitmap!

In the Arduino IDE you can click on the neoAnim.h tab and change the framerate to 24 FPS if you like, or play around with different framerates to slow down or speed up the the loop.

With some code tweaks you could even use this technique on external NeoPixel rings and strips!

From here, the rest is in your hands! Try different patterns, gradations, color noise, and so on to see what you can create.

This guide was first published on Nov 07, 2016. It was last
updated on Nov 07, 2016.

OUT OF STOCK NOTIFICATION

YOUR NAME

YOUR EMAIL

You have been successfully subscribed to the Notification List for this product and will therefore receive an e-mail from us when it is back in stock!

For security reasons, an e-mail has been sent to you acknowledging your subscription. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item.

If, for any reason, you would like to unsubscribe from the Notification List for this product you will find details of how to do so in the e-mail that has just been sent to you!