Code with MakeCode

You can code your Crickit and Circuit Playground Express using MakeCode! If you aren't already familiar with MakeCode, check out this guide to get started, then return here when you're ready.

Crickit Extension

The good folks at Microsoft's MakeCode team have been busily adding Crickit functionality to MakeCode! Currently, this works with the beta version of MakeCode, so click this link to get started. Then, create a new project.

To enable Crickit functionality in MakeCode, click on the Advanced category, then click on Extensions.

Then, type 'crickit' in the text field and press enter. The Crickit package will appear. Click on it and it'll be added to MakeCode!

Now that the package has been added, you'll see a new block category appear named Crickit

Click on the Crickit category to see all of the things you'll be able to do.

Crickit Run Motor

We'll start with the fundamental block for our program -- crickit run motor

Add one of these blocks to the Forever block. This will cause Motor 1 to run at half speed, forever!

Name and download the program, saving the .uf2 file to a directory you can easily find.

Then, plug the Circuit Playground Express (CPX) into you computer over USB (make sure to plug into the CPX USB port, not the one on the Crickit, which is used for occasional firmware updates) click the reset button on the CPX once to enter bootloader mode. Copy the .uf2 file to the CPX by dragging it to the CPLAYBOOT drive that appears.

Make sure the battery pack is plugged into the Crickit, and that the Crickit's power switch is in the 'on' position.

When the Circuit Playground Express restarts, it will tell the Crickit to run the motor. It's alive!!

Button Activation

It's convenient to set up start and stop buttons for the motor. We can use the two that are built onto the Circuit Playground Express.

From the Input category, add an on button A click block. Since we won't have the motor run forever anymore, drag the crickit run motor block out of the forever block and into the new button block. You can delete the forever block.

Stop Button

Add another button block, this time changing the dropdown menu to button B.

From the Crickit category, add a crickit stop motor block to the button B block.

Speed Control

What if we want to have a couple of different speeds to run the automaton? One way is to use the slide switch on the CPX to change the crickit run motor speed percentage between to preset values.

To do this we'll create a variable called speed. Then, we'll us this variable in place of the current fixed value of 50% that is in the crickit run motor block.

Our slide switch will change the value of the speed variable depending upon its position.

Click on the Variables category and Make a Variable... named speed.

Drag the speed variable to the crickit run motor block.

Startup Speed

When the program starts, we need to specify the value of speed in case the button A is pressed before the slide switch it moved. From the Loops category, add an on start block. Then, drag from the Variables category a set speed to block and set the value to 40.

Switch Control

Now, from the Input category, add an on switch moved left block. Duplicate the set speed to 40 block by right clicking on it and choosing Duplicate. Drag this copy to the switch block.

Duplicate the left swtich block, and change the dropdown menu item to right. Change the set speed to value to 80.

And there we have it! Download this .uf2 file and copy it to your Circuit Playground Express and now you'll be able to start and stop the automaton and run it at two different speeds. Note, you'll need to press the A button to activate the speed change after flipping the switch. Can you think of a way to adjust the program so this happens automatically when the switch is changed?

NeoPixel Speed Indicator

Here's the program with a few blocks added from the NeoPixel category to show low and high speed colored indicators.

You can download this copy below if needed.

Next, we'll connect the brains to the machine!

This guide was first published on Jun 04, 2018. It was last updated on Jun 04, 2018. This page (Code with MakeCode) was last updated on Jun 14, 2019.