This guide will show you how to build your own musical snake charmer box with Blinka, the circuit python! The materials you can find around the house and the project uses the Circuit Playground Express microcontroller programmed in Microsoft MakeCode for easy upload and changes.

Materials

Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
$24.95
In Stock
This high-torque standard servo can rotate approximately 180 degrees (90 in each direction). You can use any servo code, hardware or library to control these servos. Good for beginners...
$12.00
In Stock
When working with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These...
$3.95
In Stock
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or...
$2.95
In Stock

In addition, for this project you will need:

  • Double sided tape
  • Scrap cardboard
  • Scissors
  • Fishing line or string - 12" long
  • Color printer

If this is your first time using Circuit Playground Express, this guide is a good launchpad to get you up and running:

https://learn.adafruit.com/adafruit-circuit-playground-express

Let's get started!

Download the PDF of Blinka by clicking the green button below.

Blinka can be printed out on any color printer. For best results print double sided on a single sheet of paper. 

Use scissors to carefully cut along the dotted lines.

A glue stick or double sided tape works well to glue the mouth together and attach the head to the body. Make sure to only add glue to the blue parts.

 

Press and hold together for a few seconds to allow the glue to set.

 

Add glue to the blue circles on Blinka's head and body. Align carefully and then press and hold these two parts together firmly.

Give Blinka a few minutes after gluing to allow the glue to take hold.

Add the fishing line

Use a pointy tool to poke two holes in Blinka's head.

These will allow us to add a bit of fishing line (or string) to connect her to the inside of the box.

Be careful not to poke your fingers while making these holes!

Once we have two holes side-by-side, it's time to thread the two ends of fishing line or string through.

Blinka is ready to go!

If you haven't used MakeCode before, this guide is a good place to start.

Getting into Bootloader Mode

Your Circuit Playground Express board comes ready to work with CircuitPython, and will show up as "CIRCUITPY" when connected to your computer. We'd like to make it work with MakeCode however, which is done by putting it into "bootloader mode". All that's required to do this is to connect the board to your computer with a micro USB cable and click the small reset button in the center of the board.  

When the Circuit Playground Express is in Bootloader mode, all the LEDs will turn red briefly, then green. Verify your status LED is also pulsing redYour computer should show a new removable drive called "CPLAYBOOT"

Drop in your code

Once you're in bootloader mode, you're ready to use MakeCode!

This will allow you to interact with the code used in this project.

Uploading code is easy, all you do is download the .uf2 file and drag 'n drop it onto the "CPLAYBOOT" drive.

The drive will automatically eject itself. (Your computer may give you a "failed to eject drive correctly" error, you can ignore this.)

This is the set of instructions that your Circuit Playground Express will follow. 

It may look like a lot at first, but what we're doing are three things in sequence: 

  1. Rotate servo quickly 100 degrees clockwise
  2. Play 'snake charmer' song
  3. Rotate servo slowly 100 degrees counter clockwise

Test it!

It's always a good idea to do a dry run before putting everything together. 

You can do this by connecting your servo motor to your Circuit Playground Express.

The servo has three wires, this is how they should connect:

Brown --> GND

Orange --> Vout

Yellow --> A2

When you press the "A" button you should see the servo rotating one way quickly, playing a short song, and then moving back slowly to its starting position.

Now it's time to bring everything together. 

To create the lifting arm you'll need a piece of cardboard about 4 inches long by 2 inches wide.

Trim one corner into a semi-circular curve. Cut the opposite corner off at about a 45 degree angle.

 

These two cuts will allow the cardboard to rotate inside the box without colliding into the floor or walls.

 

Add a piece of double sided tape to the rounded corner of the cardboard. Trim any excess tape that extends past the cardboard edge.

Stick your piece of cardboard to the servo as pictured.

 

This will become our lifting mechanism.

Now it's time to mount the servo motor inside the box. 

Make sure to give the lifting arm enough clearance! 

 

Place the servo inside the box and use a pen to mark exactly where you will place it. 

Now add a piece of tap to the bottom of the servo motor.

 

This will hold it in place inside the box.

Press it firmly into place. Motor mount complete!

Just add Blinka

Now it's time to give Blinka a home inside the box.

Lift her carefully into the box, making sure to keep her spiral shape intact.

Poke two hole in the top of the box, about an inch away from the front edge. 

 

Feed the two ends of the string or fishing line through these holes and tie them off.

 

Two simple knots are sufficient to hold Blinka in place.

Check Blinka's placement within the box, ensuring that her tongue doesn't get caught as the box lid closes.

Now you can hook up your Circuit Playground Express, connect to power, and test your snake charming abilities!

Using Different Inputs

By default this MakeCode example is set up to use the A button as a trigger, but it is easy to use other inputs to trigger your box.

Try it out! https://makecode.adafruit.com/49951-32099-41050-46072

Perhaps you want Blinka to pop our of her box as soon as someone enters a room and turns on the light? Easy! Click the pink "Input" button and drag the "on light dark" into the code space. You can use the dropdown menu on this block to change it to respond to sudden bright light instead of sudden darkness. 

Now drag the whole block of code into your new "on light bright" trigger.

Uploading New Code

To replace your old code with this new version, download the updated .uf2 file.

It is sometimes helpful to rename your code so you don't get confused which version is which.

BUT WHERE'S MY CPLAYBOOT? 

Make sure your CPX is connected to your computer, then press the reset button in the center of the board again. The board should flash red and then go green. This means it's ready to accept new code.

Drag and drop your fresh .uf2 file onto the CPLAYBOOT drive and like magic it will automatically update & eject itself.

Done! Blinka will now respond to a sudden bright light instead of the button press.

You use different inputs to get Blinka to react to a loud sound or a sudden shake, just by dragging the code into a different input block!

If you want to continue exploring you can check out lots more MakeCode projects on the Adafruit Learn System:

https://learn.adafruit.com/category/makecode

 

This guide was first published on May 07, 2018. It was last updated on May 07, 2018.