Programming
This guide shows how to install Circuit Python on the Circuit Playground Express. The example code provided below is by Phillip Burgess in the Jack-O-Lantern project.
Install CircuitPython
The Adafruit Circuit Playground Express ships with CircuitPython but lets go ahead and update it to the latest version. It's super easy with the circuitpython.org website, just click the link below to launch the page. There you can choose to install stable release or beta.
Quick Start
- Connect board to computer via a known good USB and double press the reset button.
- Download circuitpython UF2 and upload to the CIRCUITBOOT drive.
- Open CIRCUITPY drive and upload the required libraries (listed below) and code.py
Adafruit Circuit Python Libraries
Download the Circuit Python library bundle and unzip the folder. Create a new folder in the CIRCUITPY drive and name it "lib". The following libraries are required to run the code properly. Double check to ensure all of the files and folders are inside the lib folder on the CIRCUITPY drive.
- neopixel.mpy
Demo Code
In this project we utilized the Jack-O-Lantern Pumpkin code as is, but you can modify the color and brightness if you wish.
# SPDX-FileCopyrightText: 2018 Phillip Burgess for Adafruit Industries # # SPDX-License-Identifier: MIT """Jack-o'-Lantern flame example Adafruit Circuit Playground Express""" import math import board import neopixel try: import urandom as random # for v1.0 API support except ImportError: import random NUMPIX = 10 # Number of NeoPixels PIXPIN = board.D8 # Pin where NeoPixels are connected STRIP = neopixel.NeoPixel(PIXPIN, NUMPIX, brightness=1.0) PREV = 128 def split(first, second, offset): """ Subdivide a brightness range, introducing a random offset in middle, then call recursively with smaller offsets along the way. @param1 first: Initial brightness value. @param1 second: Ending brightness value. @param1 offset: Midpoint offset range is +/- this amount max. """ if offset != 0: mid = ((first + second + 1) / 2 + random.randint(-offset, offset)) offset = int(offset / 2) split(first, mid, offset) split(mid, second, offset) else: level = math.pow(first / 255.0, 2.7) * 255.0 + 0.5 STRIP.fill((int(level), int(level / 8), int(level / 48))) STRIP.write() while True: # Loop forever... LVL = random.randint(64, 191) split(PREV, LVL, 32) PREV = LVL
More Projects!
Check out these projects below, they're all using Circuit Playground express.
Project Examples
Page last edited January 22, 2025
Text editor powered by tinymce.