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.
Any of these M4 boards will do nicely.
To play the notes, you'll need a buzzer. For the interface you'll need an OLED display and a couple buttons.
- A small solderless breakboard
- wires for use of the breadboard
- microUSB data cable fro connecting the M4 board to your computer
Key image byan is CC BY-SA 3.0