Overview

This guide is part of a series on some of the more advanced features of Python, and specifically CircuitPython. Are you new to using CircuitPython? No worries, there is a full getting started guide here.

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. You can learn about Mu and its installation in this tutorial.

With the introduction of the new SAMD51 (M4) based boards, CircuitPython gets far more interesting. Not only do they have a clock speed almost three times faster than the SAMD21 (M0 boards) and they have six times as much RAM. Not only do CircuitPython programs run significantly faster, they can be much larger and/or work with much more data. With this space comes the capability to move beyond simple scripts to more elaborate programs.

The goal of this series of guides is to explore Python's mechanisms and techniques that will help make your more ambitious CircuitPython programs more manageable, understandable, and maintainable.

In this guide, we'll look at several basic ways to organize data in Python: Tuples, Lists, and Dictionaries.

We'll use examples that deal with playing tunes using the Adafruit pulseio library. Below is the circuit used featuring an Adafruit ItsyBitsy M4 Express. With a few minimal tweaks to the wiring and code, this will work with any of the M4 Express boards. Note that only the final example makes use of the buttons and an OLED display.

Parts

Any of these M4 boards will do nicely.

1 x ItsyBitsy M4 Express
ATSAMD51 based ItsyBitsy with extra flash.
1 x Feather M4 Express
ATSAMD51 based Feather with extra flash.
1 x Metro M4 Express
ATSAMD51 based Metro with extra flash.

To play the notes, you'll need a buzzer. For the interface you'll need an OLED display and a couple buttons.

1 x Piezo buzzer
Piezo buzzer that you can drive with any frequency square wave.
1 x Breadboardable tactile button
Little clicky switches are standard input "buttons" on electronic projects.
1 x 128x32 I2C OLED display
Small, but very readable OLED display with an I2C interface.

Tools and Materials

  • A small solderless breakboard
  • wires for use of the breadboard
  • microUSB data cable fro connecting the M4 board to your computer

Key image by Jorge Stolfi an is CC BY-SA 3.0

This guide was first published on Jul 13, 2018. It was last updated on Sep 21, 2018. This page (Overview) was last updated on Sep 20, 2018.