# MakeCode for Circuit Playground Express

## What is MakeCode?

![](https://cdn-learn.adafruit.com/assets/assets/000/048/088/medium800thumb/makecodedragdemo.jpg?1510260958)

 **Microsoft MakeCode for Adafruit&nbsp;** is a web-based code editor&nbsp;for physical computing. It provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users. **Try it now at&nbsp;[https://makecode.adafruit.com/](https://makecode.adafruit.com/)&nbsp;!**

Some of the key features of MakeCode are:

- **web based editor:** &nbsp;nothing to install
- **cross platform:** &nbsp;works in [most modern browsers](https://makecode.adafruit.com/browsers) from tiny phone to giant touch screens
- **compilation in the browser:** &nbsp;the compiler runs in your browser, it's fast and works offline
- **blocks + JavaScript:** &nbsp;drag and drop blocks or type JavaScript, MakeCode let's you go back and forth between the two.
- **works offline:** &nbsp;once you've loaded the editor, it stays cached in your browser.
- **event based runtime:&nbsp;** easily respond to button clicks, shake gestures&nbsp;and more

MakeCode currently supports the&nbsp; **Adafruit Circuit Playground Express****.** For other boards, like the Adafruit Metro M0, try [https://maker.makecode.com](https://maker.makecode.com)&nbsp;.

&nbsp;

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### Circuit Playground Express - Base Kit

[Circuit Playground Express - Base Kit](https://www.adafruit.com/product/3517)
It's the **Circuit Playground Express Base Kit!** &nbsp;It provides&nbsp;the few things you'll need to get started with the new [Circuit Playground Express](https://www.adafruit.com/product/3333).&nbsp;This version of Circuit Playground is super powered, and will...

In Stock
[Buy Now](https://www.adafruit.com/product/3517)
[Related Guides to the Product](https://learn.adafruit.com/products/3517/guides)
![Rectangular case for Circuit Playground Express - Base Kit.](https://cdn-shop.adafruit.com/640x480/3517-04.jpg)

Warning: 

https://makecode.com/_dJzHC09Xxc1v

# MakeCode for Circuit Playground Express

## Editing Blocks

The block editor is the easiest way to get started with MakeCode. You can drag and drop blocks from the category list. Each time you make a change to the blocks, the simulator will automatically restart and run the code. You can test your program in the browser!

- try our [getting started tutorial](https://makecode.adafruit.com/#tutorial:getting-started) that helps you build a siren program
- [try one of our projects](https://makecode.adafruit.com/projects) to learn more about the features of the Circuit Playground
- our favorite way to learn is by watching MakeCode Live with John Park, either the [playlist of recorded videos](https://www.youtube.com/watch?v=Km9gjuPbPfk&list=PLjF7R1fz_OOVzwViKb2YwYNPHmqJbCJ2q), or by watching it live on Tuesdays at 3pm ET on the [Adafruit Youtube Channel](https://www.youtube.com/c/adafruit/)
- take a [deep dive in the&nbsp;documentation](https://makecode.adafruit.com/docs)

https://youtu.be/ByuLe_lMHUU

## Blinky!

Let's show how MakeCode works by building a simple program that blinks the 10 awesome NeoPixels.

Creating a blink effect is done by setting all the ring LEDs to red, **pause** for a little, then turn them off, pause for a little, then repeat **forever**.

Let's gather the blocks we need to convert the description above into Blocks that the Circuit Playground can understand and run:

* **forever** runs blocks in a loop with a 20ms pause in between (it is similar to Arduino **loop**).
* **show ring** sets the color on the 10 neopixels at once
* **pause** blocks the current thread for 100ms. If other events or forever loops are running, they have the opporunity to run at this time.


 **Do you want to select or change colors?** &nbsp;The **show ring** block has a built-in color picker. Select the color from the color wheel to select a color, then click one of the ten Neopixel rings to modify its color.&nbsp;

**How do I disable a Neopixel?** &nbsp;The grey dot in the middle of the color wheel indicates that the pixel is&nbsp;off. Select the grey from the color wheel and then click the Neopixel ring.&nbsp;

You can see the Blinky block program in action in the MakeCode editor below.&nbsp;You can also see how the blocks are "slotted together". Clicking the question marks on the box will pop-up a comment to explain what the block does.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/055/440/medium800/makecode_image.png?1529026261)

[Click here to open up the MakeCode editor with this project!](https://makecode.com/_91sUqiKLzL9r)
In the next section, we'll load the Blinky code onto the Circuit Playground Express!&nbsp;

# MakeCode for Circuit Playground Express

## Downloading and Flashing

Getting your code into your device is very easy with MakeCode. You do not need to install any software on your machine and the process takes two steps:

* Step 1: Connect your board via USB and enter **bootloader mode**
* Step 2: **Compile and Download** the .uf2 file into your board drive


We are going to go through these two steps in detail.

## Step 1: Bootloader mode

Connect your board to your computer via a USB cable. Press the reset button once to put the board in bootloader mode. 

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/041/826/medium800thumb/led_strips_3333_giffy1.jpg?1494958971 Push the reset button)

When the Circuit Playground Express is in Bootloader mode, all the LEDs will turn **red briefly, then green. Verify your status LED is also pulsing red****.** Your computer should show a new removable drive called "CPLAYBOOT"

&nbsp; **If the LEDs are all&nbsp;red:** Either the computer is still installing drivers (Please wait a minute, Windows takes some time to install updates.) or you have a bad USB connection. If you keep getting red LEDs - try a new USB cable (you may want to ensure your USB cable is not charge only, it needs to transfer data) or a different USB port.

https://youtu.be/fYwEmrMg22o

Once your LEDs are all green, you should see a CPLAYBOOT drive appear in your drive list in your file explorer.

**We are now ready to compile our blinky code and download it to our board!&nbsp;**

## Step 2: Compile and Download


 **Let's first verify that our code compiles properly in MakeCode**.

MakeCode has a built-in simulator that re-loads and re-runs code when restarted. This is an easy way to both ensure that our code compiles and simulate it before moving it onto the board. The refresh button re-loads the simulator with your latest version of block code.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/042/257/medium800/circuit_playground_compile.png?1496431056)

Warning: 

If your board is working in the simulator, it's time to download it to your actual board! Click the "Download" &nbsp;button. It will generate a .uf2 file and download it to your computer ([UF2](https://github.com/Microsoft/uf2) is a file format designed to flash microcontrollers over USB).

![](https://cdn-learn.adafruit.com/assets/assets/000/042/259/medium800/circuit_playground_makecode-download-button.png?1496431515)

**General Steps to copy over your program (not specific to any Operating system)**

1. &nbsp;Ensure your board is in bootloader mode.
2. Find the .uf2 file generated by MakeCode in&nbsp;your file explorer. Copy it to the "CPLAYBOOT" volume.&nbsp;
3. The status LED on the board will blink&nbsp;while the file is transferring. Once it's done transferring your file, the board will automatically reset and start running your code (just like in the simulator!)

Info: 

https://youtu.be/8rjk5iNQAqw

 **Windows:&nbsp;** Open Windows Explorer (Windows key + E key) and locate the "blinky.uf2" file you generated. It's probably in&nbsp; your **Downloads** folder!

You can copy/paste the file to your **CPLAYBOOT** volume or you can drag/drop it like in the GIF below.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/042/260/medium800thumb/circuit_playground_file-transfer-win.jpg?1496432300)

 **macOS** : Open Finder and locate the "blinky.uf2" file. You can copy/paste this file to the "cplayboot" volume or drag/drop it from the same finder window.&nbsp;

 **If you want to avoid the copying process** : You can download your programs directly to the board. To do this: change the download location in [Chrome](https://support.google.com/chrome/answer/95759?co=GENIE.Platform%3DDesktop&hl=en), [Firefox](https://support.mozilla.org/en-US/kb/where-find-and-manage-downloaded-files-firefox?redirectlocale=en-US&redirectslug=Downloads+window), [Safari](https://support.apple.com/kb/PH21464?locale=en_US), or [Opera](http://help.opera.com/Windows/12.10/en/downloads.html)to the main directory of your "CPLAYBOOT" volume.

## Running MakeCode that's Already Loaded

If you unplug your board and then plug it back in again to your computer, it may not run the program again automatically. If it instead shows all green NeoPixels, just press the reset button and your program will start.

# MakeCode for Circuit Playground Express

## Saving and Sharing

Want to change the Blinky program to display different colors, or make it play a sound? Editing the program on your Circuit Playground is super easy!&nbsp;

## Extracting your code from the Circuit Playground
![](https://cdn-learn.adafruit.com/assets/assets/000/042/337/medium800thumb/circuit_playground_Untitled.jpg?1496605029 El archivo .uf2 contiene el programa y el código fuente)

The .uf2 file **(CURRENT.UF2)**&nbsp;you created by clicking on the Compile button in MakeCode also contains the source code of your program!

You can open this file in MakeCode by dragging and dropping it into the browser to edit it.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/048/091/medium800/makecode_adafruitsharing.png?1510264577 Compartiendo el proyecto)

## Sharing

You can share your code by clicking on the **share** button. After confirmation, MakeCode will create a short unique URL for your code. Anyone with that URL will be able to reload the code.

These URLs can also be used to embed the editor your blog or web pages! Just copy paste the URL in your text editor and (if it supports oEmbed) it will automatically load it in your page.

# MakeCode for Circuit Playground Express

## Editing JavaScript

If you already have some experience coding or you feel ready to take the next step, MakeCode features a fully-feature JavaScript editor in the browser! 

* [read the JavaScript docs](https://makecode.adafruit.com/javascript)

Give it a try!



You can also switch between blocks and JavaScript by clicking the button on the top.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/055/442/medium800/makecode_Selection_158.png?1529026614 Botón para editar en código)

[Click here to see this example in the MakeCode editor!](https://makecode.com/_bjY2VdKo7VpJ)
# MakeCode for Circuit Playground Express

## Apps

MakeCode also provides various apps to provide additional features not available in browsers.

# Windows Store

The [MakeCode for Adafruit](https://www.microsoft.com/en-us/store/p/makecode-for-adafruit/9pgzhwsk0pgd) Windows Store app.

* **Super fast HID-based flashing**: no more drag and drop.
* Reading debug message and surfacing them in the editor (debug messages are sent over HID not CDC Uart/Serial)

# Node.JS

The (open source) [GitHub repo](https://github.com/microsoft/pxt-adafruit) contains instructions to run a local node.js web server with HID flashing and serial monitoring.

# MakeCode for Circuit Playground Express

## WebUSB Uploading

## One-Click Deploy

Are you tired of dragging and dropping your UF2 files over and over again? Well then WebUSB upload is for you! With WebUSB, you can upload your code directly to your board without having to save a UF2 file and then dropping it onto the flash drive. Just plug keep the USB cable plugged into your computer and upload code as many times as you need!

## Requirements!

You'll need to do a few things before you can use WebUSB

- **You will need to use the latest version of the [Google Chrome](https://www.google.com/chrome/) web browser.** Firefox, Safari, Opera, Edge, etc do not support WebUSB at this time. Only Chrome, only versions 68 or greater!&nbsp;
- Run Windows 10, Latest Mac OS X or Linux. Windows 7 or 8 is not supported!

## Update Bootloader

You will also need the latest bootloader firmware for Circuit Playground Express (which only needs to be done once). We ship the newest bootloader on Circuit Playground Expresses as of July 2018 but in case you have an old one, it doesn't hurt!

[Click to download the latest Circuit Playground Express bootloader](https://github.com/adafruit/uf2-samdx1/releases/latest/update-bootloader-circuitplay_m0*.uf2)
Updating the bootloader is as easy as flashing a MakeCode program. Simply enter the bootloader by pressing Reset once (or twice) to get a green ring of NeoPixels. A flash drive called **CPLAYBOOT** will show up in your operating system's file explorer/finder. Drag the&nbsp;_update bootloader uf2_&nbsp;file you downloaded via the green button to the **CPLAYBOOT** drive. This uf2 contains a program which will unlock the bootloader section, update the bootloader, and re-lock it. It will overwrite your existing code such as CircuitPython or Arduino so make sure everything is backed up!

## Special MakeCode URL

Once you have it up and running, you'll need to go to the special MakeCode link with WebUSB enabled. Use the green button below or copy+paste the full URL into your browser: [https://makecode.adafruit.com/?webusb=1#editor](https://makecode.adafruit.com/?webusb=1#editor)

[MakeCode WebUSB Beta](https://makecode.adafruit.com/?webusb=1#editor)
## Projects & Extensions

Your existing projects should remain in the MakeCode site so you don't need to copy anything over. However, if you had any extensions installed, you will need to reinstall them. This can be done by clicking on the extension menu and selecting the extension.

## First Time Setup

Once you have chrome and the makecode beta URL open, you will need to download a blank program to the Circuit Playground Express. With the programming area blank, click the pink Download button in your project window. Save the UF2 file to your hard drive. Place the Circuit Playground Express into bootloader mode by pressing the Reset button once (or twice) to get a green ring of lights. Copy your UF2 file from your hard drive to the CPLAYBOOT drive that appears on the list of your computer's drives when the board was placed into bootloader mode. When the UF2 file copies over, the board will reset.

![makecode_mcode-uf2-setup.gif](https://cdn-learn.adafruit.com/assets/assets/000/058/504/medium640thumb/makecode_mcode-uf2-setup.jpg?1533244849)

This is required in order to access the WebUSB functionality from Google Chrome. You only need to do this once, this first time! After copying this UF2 over, hopefully it'll be the last time you'll drag and drop one to your device!

## Pair Device

Once the initial UF2 has been copied over to the flash drive, click on the cog wheel icon in the top right corner, next to the Microsoft logo. Find the **Pair Device** link in the menu and click it.

![makecode_mcode-pair-device.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/499/medium640/makecode_mcode-pair-device.jpg?1533241366)

## Connect PXT Device

Once you've clicked on Pair device, a popup window should appear below the browser URL input box. Click the blue connect button to establish connection between your PXT device and browser.

![makecode_mcode-pxt-connect.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/500/medium640/makecode_mcode-pxt-connect.jpg?1533241440)

## Device Paired!

You'll get a nice notification near the bottom of the screen letting you know the device was successfully paired. Give it a try and click on the big download button to upload your code!

![makecode_mcode-connected.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/501/medium640/makecode_mcode-connected.jpg?1533241552)

## Notes & Thoughts

You do not have to re-pair your device each time you disconnect the USB cable. However, if you find the upload button stops working or gets hung up, you can attempt to pair the device again using the same method. If you still can't get connection, try using a different USB cable. It MUST be a USB " **data**" cable. If you still are having issues, use the **support** link under question mark icon next to the cog wheel icon in the top right.

![makecode_mcode-support.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/502/medium640/makecode_mcode-support.jpg?1533241925)

# MakeCode for Circuit Playground Express

## Other Good Stuff

This guide is meant as a starter block but it's worth mentioning briefly about other feature of MakeCode...

## GitHub packages

Additional blocks or drivers can be packaged in github repo and loaded in the editor via the **Add Package** dialog. Packages can contain JavaScript, C++ and yes! ASM! https://makecode.adafruit.com/packages

## We are Open Source on GitHub

Checkout https://makecode.com/about for more info about the various repos.

## We have crowd-sourced translations

Whether you want to code in Klingon or your native non-English language, MakeCode supports crowd sourced translations at https://makecode.adafruit.com/translate. 



# MakeCode for Circuit Playground Express

## See More MakeCode Projects


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Circuit Playground Express - Base Kit

[Circuit Playground Express - Base Kit](https://www.adafruit.com/product/3517)
It's the **Circuit Playground Express Base Kit!** &nbsp;It provides&nbsp;the few things you'll need to get started with the new [Circuit Playground Express](https://www.adafruit.com/product/3333).&nbsp;This version of Circuit Playground is super powered, and will...

In Stock
[Buy Now](https://www.adafruit.com/product/3517)
[Related Guides to the Product](https://learn.adafruit.com/products/3517/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [New Year Countdown Clock with Circuit Playground Express](https://learn.adafruit.com/new-year-countdown-clock-with-circuit-playground-express.md)
- [Micro USB Dock for Circuit Playground](https://learn.adafruit.com/micro-usb-dock-for-circuit-playground.md)
- [Circuit Playground Hourglass](https://learn.adafruit.com/circuit-playground-hourglass.md)
- [CircuitPython 101: Basic Builtin Data Structures](https://learn.adafruit.com/basic-datastructures-in-circuitpython.md)
- [Circuit Playground Seashell Pendant](https://learn.adafruit.com/circuit-playground-seashell-pendant.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [Trash Panda](https://learn.adafruit.com/trash-panda-circuit-python-crickit.md)
- [Using EduBlocks with Circuit Playground Express](https://learn.adafruit.com/using-edublocks-with-circuit-playground-express.md)
- [Qu'est-ce que MakeCode?](https://learn.adafruit.com/makecode-fr.md)
- [Using MCP23008 & MCP23017 with CircuitPython](https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython.md)
- [Make it Move with Crickit](https://learn.adafruit.com/make-it-move-with-crickit.md)
- [Steven Universe Cosplay Shirt & Gem](https://learn.adafruit.com/steven-universe-cosplay-shirt-gem.md)
- [Rose's Shield - Steven Universe](https://learn.adafruit.com/rose-s-shield-steven-universe.md)
- [Make It Shake, Rattle, and Roll: Accelerometer Use](https://learn.adafruit.com/make-it-shake-rattle-and-roll.md)
- [Make It a Mouse](https://learn.adafruit.com/make-it-a-mouse.md)
