MakeCode for CRICKIT // Circuit Playground Express

MakeCode is this programming editor that runs in a web browser. It’s has an intuitive interface that’s both block based and text editor.

It works with Adafruit's CRICKIT and Circuit Playground Express so you can make interactive projects with the on-board sensors and components. You can drag & drop blocks to make interactive programs using lights and sounds without having to solder or learning a new syntax.

You can upload code directly to the Circuit Playground Express with WebUSB is you follow this guide page for when you run MakeCode.

Setup Circuit Playground Express for MakeCode

To get started, we'll need to head over to the Adafruit MakeCode website and follow the steps below.

  1. Plug in your Circuit Playground Express with a USB Cable
  2. Press the RESET button. Green light means you're ready to MakeCode
  3. Download the UF2 file and drop it onto CPLAYBOOT.

Install CRICKIT Extension for MakeCode

 

On the MakeCode site, click on New Project. In the list of blocks, select ADVANCED and then EXTENSIONS. Click on the Crickit block that shows up and install Crickit support! You will now have a new CRICKIT bin of blocks you can use! Continue on to learn how to use these blocks. Read the full guide here for more info.

Mapping Pot to Motor Speed

 

In the forever loop we can add a crickit run motor code block. Instead of entering a % value for motor speed, use a map code block to link values from a potentiometer to the motor block. Map blocks are found in the MATH category. Use a crickit analog read signal code block to assign a channel where the potentiometer is connected. From low to high, use 0 – 1023. For the second input set, use values 0 – 100%. You might need to tweak the map to run from 0 – 1023 to 25 – 100 since the first quarter of the motor doesn't really move. A pause block with 100ms is the minimum required delay. 

The code block pictured is actually a really long block so we broke it up into three parts. You can use Javascript mode to make it easier to copy and paste code.

Upload and Test Code

Once you have your CPX setup with the MakeCode UF2, try testing it out by uploading the code to the board. Click the link below to open up the program in MakeCode. Click on the pink edit icon near the top of the title to open the code. This will create a project in MakeCode and allow you to edit, modify and upload the code to the board. 

CircuitPython

The Adafruit Crickit and Cricuit Playground Express can run CircuitPython for programming fast and easy to read code. Use the special Crickit CPX build firmware and follow the learn guide for setting up the board. This special build includes libraries so it saves space and gets you quickly up and running. 

Upload Python Code

 

We recommend using the Mu editor for writing your python code. It's a simple Python editor for beginner programmers. Follow the Introductory Guide to CircuitPython to learn how to setup Mu.

import time
from adafruit_crickit import crickit

#setup seesaw
ss = crickit.seesaw

#pot connected to signal #1
pot = crickit.SIGNAL1

# make variables for motors
motor_1 = crickit.dc_motor_1


while True:
    print((ss.analog_read(pot),))  # log helper
    motor_1.throttle = ss.analog_read(pot) / 1023  # convert analog 0->1023 to 0->1.0
    time.sleep(0.01)

This guide was first published on Aug 28, 2018. It was last updated on Aug 28, 2018.

This page (Software) was last updated on Aug 24, 2018.

Text editor powered by tinymce.