What is MakeCode?

MakeCode is a web-based code editor for physical computing made by Microsoft.

What does that mean for you? It means you can program your Circuit Playground Express to do almost anything you can dream up right from a website! You can code with blocks similar to the language Scratch, or you can do more advanced coding with Javascript. We'll be sticking to the block-based programming for this project.

More on MakeCode for Adafruit boards here.

Install the MakeCode CRICKIT Extension

Before we start programming, let's make sure you have the CRICKIT extension installed in MakeCode.

Detailed instructions on how to do that can be found in this guide.

Create a New Project with MakeCode

Head over to https://makecode.adafruit.com/ and create a new project.

Click the button below to access the code for this project.

What's going on the code above?

  • On start, we initialize the NeoPixel strip.
  • In a forever loop, we set the brightness of the NeoPixels, set the CPX NeoPixels to a specific color, call the comet animation for the NeoPixel strip for 3 seconds, set the volume of the CPX speaker, then play the "Do Your Ears Hang Low" tune by calling the song functions. As it's a forever loop, this code block loops forever regardless of other events that happen in the code!
  • The "Do Your Ears Hang Low" tune can be separated into 3 parts. The song starts with part 1, then goes to part 2, then back to part 1 then ends with part 3 before repeating again (and again and again...). Creating functions for these song parts then "calling" the functions later allows us to have much cleaner looking and more organized code. It also allows us to reduce the amount of code needed for the project making the program more efficient!
  • When capacitive touch input A3 on the CPX is touched, we want to call the wave function (which makes Adabot wave with ice cream in hand), then move the DC motors each at 65% speed for 8 seconds, stop the motors, then call the wave function again.
  • The wave function starts the servo at 0 degrees, then moves to 150 degreesthen back to 0, repeating 5 times in total.

Uploading the Code

Now that we have the code for the project, we need to upload it to the CPX.

Let's name our file and download it.

  • Choose a name at the bottom of the page.
  • Then click the pink Download button.

Follow the directions and connect your CPX to your computer via the usb cable. Click the CPX Reset button once to go into programming mode (all NeoPixels will turn green).

In some cases, you may need to press the reset button twice to get into programming mode.

Next, look for the file in your downloads folder and drag it onto your CPLAYBOOT drive that should have showed up in your file manager/finder when you plugged in your board and entered programming mode.

You should now see the CPLAYBOOT drive disappear.

Power up CRICKIT

Connect CRICKIT to power with the 5V DC power cable

The code should now be running so try it out!

  • When the board is powered up, the NeoPixels on both the CPX and CRICKIT should come on and "Do Your Ears Hang Low" should start playing.
  • When the tin foil is touched, the servo should move back and forth five times, then the motors should both turn for eight seconds. Lastly, the servo will move back and forth five more times.

If you are having issues getting things to work check out this extended guide here.

This guide was first published on Nov 20, 2018. It was last updated on Mar 08, 2024.

This page (Programing with MakeCode) was last updated on Mar 08, 2024.

Text editor powered by tinymce.