If you'e like to use MakeCode for this project rather than CircuitPython, follow the instructions on this page.

Note that the circuit used here is slightly modified to work with MakeCode.

The current iteration of this code is stable in MakeCode/beta. Make sure you're URL says makecode.adafruit.com/beta#editor

Getting Familiar

Microsoft MakeCode for Adafruit is a web-based code editor that provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users.

If you'd like to learn more about MakeCode, this guide is a good place to start.

How to Upload Code

To upload code, connect you Circuit Playground Express to your computer using a micro USB cable and press the small reset button in the center of the board. All the LEDs will flash red briefly, then turn green. Your computer should now show removable drive called CPLAYBOOT. 

Click the Download button to download the .uf2 file to your computer, and drag 'n drop that .UF2 file onto the CPLAYBOOT drive in your computer's file explorer or finder.

The drive will automatically eject itself (your computer may give you a "failed to eject drive correctly" error, you can ignore this). The code is now on your Circuit Playground Express and ready to run!


Click the button below to enter the portal to interact with the code for this project

The Logic

The code for this project employs a tricky bit of logic to get the buttons to respond as they do. 

The not_ function returns true if the input is false, and false when the input is true. In this way, the servo motors are instructed to maintain the specified angle until a signal from the button is detected.

A single forever loop is used to link each of the 4 input buttons to the 4 servo motors that will animate the limbs of the marionette. 

Depending on your setup, you may want to tweak the angles that each servo moves by changing the values in the crickit set servo # angle to 40. Keep in mind that the servos are placed in a mirror arrangement, so increasing the angle range for one will require decreasing that range for its mirror opposite. Some trial & error to sort this out is normal.

Once the code is uploaded to CPX you're ready to start putting the circuit together. 

Signals & Servos

We will be utilizing 4 out of the 8 possible Signal I/O ports on CRICKIT to connect the buttons, and using up all 4 servo ports to plug in each servo. 

For a deeper dive into using input and output signals with CRICKIT, reference this guide.

Circuit Diagram

To use MakeCode for this project, we need to add some 1K pull up resistors to our circuit. These will allow the state of the buttons to be detected by the program.

If you'd prefer not to use a breadboard, resistors can be stuck directly into the signals port on the Crickit.

The resistors should connect the Signals line with the 3.3V line.

This guide was first published on Feb 27, 2019. It was last updated on Feb 27, 2019.

This page (Coding with MakeCode) was last updated on Apr 08, 2021.

Text editor powered by tinymce.