Uploading Code with Mu

But first...

To use Circuit Playground Express and CRICKIT together, you'll first need to install the special 'seesaw' version of the CPX firmware. This guide will take you through how to install CRICKIT support onto your circuit playground express.

Adafruit recommends the Mu editor to easily craft and load your code to your CircuitPython projects. You can learn more about Mu by reading this guide.

Once you have completed these steps, you're ready to move on.

Get Ready!

  1. Connect the MicroUSB for coding from the Circuit Playground Express to your computer
  2. Put 3 AA batteries in a battery pack and connect to the Crickit, or use a wall adapter
  3. Turn on the Crickit, check that the switch next to the DC power plug is ON

Connect Motor

Now it's time to test the code and make sure the DC motor runs. 

First, connect your motor to the CRICKIT as pictured, using a small screwdriver to tighten down the screws.

Copy and paste the code below into your Mu editor.

Save this code to your CIRCUITPY drive as code.py

import time
from adafruit_crickit import crickit

# Create one motor on seesaw motor port #1
motor = crickit.dc_motor_1
motor.throttle = 0.5  # half speed forward

# Create drive (PWM) object for the lights on Drive 1
lights = crickit.drive_1
lights.frequency = 1000 # Our default frequency is 1KHz

while True:
    lights.fraction = 0.5  # half on
    time.sleep(0.8)

    lights.fraction = 0.2  # dim
    time.sleep(0.1)

    # and repeat!
Make sure the file saved to CIRCUITPY is named "code.py", this will allow it to run automatically when your CPX is powered on.
If you're motor doesn't spin at first, make sure the Crickit is powered with the battery pack and the slide switch on your Crickit is in the "ON" position. Look for the green LED next to the HAPPY FACE icon.

Troubleshooting

Problem: My motor still won't spin!

Solution: Check that you have a 5V power supply attached to the DC jack on your CRICKIT board.

 

Problem: My Circuit Playground Express isn't recognized by Mu!

Solution: Make sure your board is set up as a CIRCUITPY device. If it is showing up at "CPLAYBOOT" on your computer, you can follow the steps in this guide to get it back into CIRCUITPY mode.

 

This guide was first published on May 18, 2018. It was last updated on May 18, 2018. This page (Uploading Code with Mu) was last updated on Sep 15, 2019.