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!! This will cause your Bumper Bot to turn in a circle. Turn off the Crickit board, and now we'll put the full program on it!

Bumper Bot Program Flow

Here's the flow we'll follow for our program:

  • Turn on the bot, it will:
    • play a sound
    • set the NeoPixels to yellow
    • move the servo flag up
  • Press button A on the CPX and it'll:
    • play a tone
    • set the NeoPixels blue
    • move the motors forward to start driving
    • flip the flag direction
  • Press button B to:
    • stop the motors
    • play a double beep
    • set pixels to magenta
    • move the flag
  • When the bot hits an object, the accelerometer shake condition is met:
    • stop both motors
    • reverse the motor direction
    • play a double beep
    • set the pixels to purple
    • move the flag
    • run both motors backwards for a little bit
    • stop Motor 2
    • run Motor 1, which causes the bot to turn
    • run the motors forward
    • set the pixels blue
    • rotate the flag

Following these steps, we create the program below. You can download the code and copy it to your Circuit Playground Express.

If you'd like to make changes, it's easy! How about different colors for the pixles? Change the sounds! Rotate the opposite direction when turning! There are so many choices for what you can do with your Bumper Bot and MakeCode!

Make sure you follow the step above to add the Crickit extension before clicking the link below! Otherwise, the editor will take you straight to JavaScript mode instead of blocks and throw some other errors.
Be sure you use the green Servo blocks under the CRICKIT group and NOT the red Servo blocks under the PINS block group!

On the next page, we'll put the bot into action!

This guide was first published on Jun 13, 2018. It was last updated on Jun 13, 2018.
This page (Code with MakeCode) was last updated on Jun 23, 2020.