Now it's time to upload the code!

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

If you haven't used MakeCode before, this guide is a good place to start.

Before you start programming...

...make sure you have the CRICKIT extension installed in MakeCode. Detailed instructions on how to do that can be found in this guide.

Once you've got that taken care of you are ready to move forward!

Getting into Bootloader Mode

Your Circuit Playground Express board comes ready to work with CircuitPython, and will show up as CIRCUITPY when connected to your computer for the first time.


We'd like to make it work with MakeCode, which is done by putting it into "bootloader mode". All that's required to do this is to connect the board to your computer with a micro USB cable and click the small reset button in the center of the board.  

The Code

Follow this link or enter the portal below to interact with the code used in this project.

Be sure you use the green Servo blocks under the CRICKIT group and NOT the red Servo blocks under the PINS block group!

How to upload code

To upload code, connect you Circuit Playground Express to your computer using the micro USB cable, click the Download button to download the .uf2 file to your computer, and drag 'n drop it onto the CPLAYBOOT drive. 

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!

What this code does

The sample sketch in MakeCode provides us with some simple commands for our obstacles. 

Firstly, in the on start block we can see that the windmill is set to start spinning as soon as CRICKIT is powered on (the volume is also set to be quite loud).

  • If you need to stop the windmill, press the B button on the Circuit Playground Express.
  • If you want to restart the windmill, press the A button and it will play a warning siren and start rotating again. 

Secondly, in the forever block, we can see that the gate is set to swing up and down in a timed pattern. This gives you a short window in which to make your shot before the gate comes slicing back down. 

If you'd like to play with the code, click "Edit" and a new window will open in which you can create your own version.

If you'd like to make the course more or less challenging, you can change the speed of the windmill in the crickit run motor 1 at 40% block. Increase it to 70%, or decrease it to 30% (note that, depending on your power supply, the DC motor may have trouble spinning below a certain threshold).

The timing of the gate can also be altered by changing the number in the pause blocks. Making these shorter or longer durations will make it easier or harder to time your putt!

It's Alive!

Plug in your battery pack and turn on power to CRICKIT and you should see your obstacles come to life!

This guide was first published on Jul 05, 2018. It was last updated on Mar 08, 2024.

This page (MakeCode for Golfers) was last updated on Mar 08, 2024.

Text editor powered by tinymce.