Konubinix' opinionated web of thoughts

Playing With Circuitpython in Circuit Playground Express

Fleeting

I appears to be a nice alternative to the using arduino uno r3

installation

as said in https://learn.adafruit.com/circuit-playground-express-circuitpython-5-minute-guide/update-circuitpython

  • download
  • press the reset button twice
  • put the file in the drive mounted for the board

playing

picocom /dev/ttyACM0 C-a C-q to quit

Shutdown the lights

import neopixel
import board
l = neopixel.NeoPixel(board.NEOPIXEL, 10)
for i in range(10):
    l[i] = (0, 0, 0)

Or, using adafruit_circuitplayground

from adafruit_circuitplayground import cp
for i in range(10):
    cp.pixels[i] = (0, 0, 0)

This unfortunately leads to RuntimeError: maximum recursion depth exceeded

So I need to trick it with

def cp():
    from adafruit_circuitplayground import cp
    for i in range(10):
        cp.pixels[i] = (0, 0, 0)
    return cp

And from the repl

from code import cp; cp = cp()

cheat sheet

Let’s map the features from the main page to the code

10 x mini NeoPixels, each one can display any color
cp.pixels
1 x Motion sensor (LIS3DH triple-axis accelerometer with tap detection, free-fall detection)
cp.acceleration

cp.detect_taps = 1 or 2 for one or two taps cp.tapped

1 x Temperature sensor (thermistor)
cp.temperature
1 x Light sensor (phototransistor). Can also act as a color sensor and pulse sensor.
cp.light
1 x Sound sensor (MEMS microphone)

While the Circuit Playground Express also has a sound sensor, this feature of the Circuit Playground library is not available for the Express.

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/sound ([2025-05-06 Tue])

1 x Mini speaker with class D amplifier (7.5mm magnetic speaker/buzzer)
TL;DR

https://learn.adafruit.com/circuitpython-essentials/circuitpython-audio-out

2 x Push buttons, labeled A and B
cp.button_a|b
1 x Slide switch
cp.switch

Infrared receiver and transmitter - can receive and transmit any remote control codes, as well as send messages between Circuit Playground Expresses. Can also act as a proximity sensor. :

https://learn.adafruit.com/ir-sensor/circuitpython

import board import pulseio pulses = pulseio.PulseIn(board.D2, maxlen=200, idle_state=True) len(pulses)

8 x alligator-clip friendly input/output pins
import board from analogio import AnalogIn

analog_in = AnalogIn(board.A1) def get_voltage(pin): return (pin.value * 3.3) / 65536

get_voltage(analog_in)

Includes I2C, UART, 8 pins that can do analog inputs, multiple PWM output
not yet
7 pads can act as capacitive touch inputs and the 1 remaining is a true analog output
cp.touch_A1..7

Green “ON” LED so you know its powered :

Red “#13” LED for basic blinking
cp.red_led = True