MakeCode for CRICKIT // Circuit Playground Express

MakeCode is this programming editor that runs in the Google Chrome web browser. It’s has an intuitive interface that’s both block based and text editor.

It works with Adafruit's CRICKIT and Circuit Playground Express so you can make interactive projects with the on-board sensors and components. You can drag & drop blocks to make interactive programs using lights and sounds without having to solder or learning a new syntax.

You can upload code directly to the Circuit Playground Express with WebUSB, see this guide page for that option.

Setup Circuit Playground Express for MakeCode

To get started, we'll need to head over to the Adafruit MakeCode website and follow the steps below.

  1. Plug in your Circuit Playground Express with a USB Cable
  2. Press the RESET button. Green light means you're ready to MakeCode
  3. Download the UF2 file and drop it onto CPLAYBOOT.

Install CRICKIT Extension for MakeCode


On the MakeCode site, click on New Project. In the list of blocks, select ADVANCED and then EXTENSIONS. Click on the Crickit block that shows up and install Crickit support! You will now have a new CRICKIT bin of blocks you can use! Continue on to learn how to use these blocks. Read the full guide here for more info.

Upload and Test Code

Once you have your CPX setup with the MakeCode UF2, try testing it out by uploading the code to the board. Click the link below to open up the program in makecode. Click on the pink edit icon near the top of the title to open the code. This will create a project in MakeCode and allow you to edit, modify and upload the code to the board. 

On Start & Forever


Let's focus on the on start and forever code blocks. Anything in the forever block will continuously run, looping forever. Stuff placed in the on start code block will run first, in the beginning of boot up. This is generally used for initial setups such as NeoPixel brightness or speaker volume. In this project, we have several function blocks that are labeled and represent a single motion.  Each of these functions contain several code blocks that tell the motors how to move. 

Crickit Code Blocks


Each code block is grouped into a section that pertains to the type of component. Here we have blocks for controlling servos, motors, NeoPixels and more. For this project, we'll only focus on motors and servos. We'll use the code blocks in the LIGHT category to control the NeoPixels on-board the Circuit Playground Express. Read through the various blocks and hover over on them to see a tool tip with description of what they do. 

Using Functions


Each function contains several code blocks that tell the motors what to do. You can create custom functions by clicking on the Make buttons in the functions category. To create forward motion using two motors, we can use the crickit tank motors code block. Using several functions allows for quick rearrangement of movements. This can aid in the creation of sequential rover movements. 

Tank Motors Code Block


This single block can control both motors by assigning a numerical value from -100 to 100. The value 0 is a full stop. A positive value  of 100 is full speed. 50 for half speed. A negative value will make the motor turn in reverse. To create rotational movements, set one motor to -100 and the other to 100. This will also result in spinning movement. Use a pause block in between motor blocks to create duration between movements. 500ms - 1000ms should be a good starting point.

Servo Control & Repeat


Program servos using the crickit set servo code block. Choose a servo number and assign a value to the angle. 0-180 will give you the available range of rotation from the servo. Use a pause block to create duration between the movements. A repeat block, found in the loops block category, can be used to create repetitive movements.

Lights & Sounds


Display dazzling NeoPixels using the show animation code block in the LIGHT category. Use the set brightness block to change the intensity. Create colored patterns using the show ring block. Create a custom function and place it in between motor movements. 

Music notes can be generated with the on-board speaker. Choose notes from a piano keyboard and write a custom jingle. Playback canned effects from the play sound code block.

This guide was first published on Jul 25, 2018. It was last updated on Mar 27, 2024.

This page (Software) was last updated on Mar 08, 2024.

Text editor powered by tinymce.