BreakingExpress

Start tinkering with the Circuit Playground Express

I have been a gadget particular person so long as I can bear in mind, so I used to be delighted after I found an Adafruit Circuit Playground Express (CPX) within the swag bag I received at PyConUS in May. I turned fascinated with these little gadgets final 12 months, when Nina Zakharenko highlighted them in her All Things Open presentation, Five Things You Didn’t Know Python Could Do, with Python-powered earrings.

After discovering one in my PyCon bag, I got down to study extra about these mesmerizing little gadgets. First, I attended a “how-to” session at one of many Open Spaces meetups at PyCon. But studying all the time requires hands-on observe, and that is what I did after I received residence. I linked the CPX system to my Linux laptop computer with a USB-to-MicroUSB cable. The unit mounts identical to any commonplace USB drive, listed as CIRCUITPY.

The CPX works on MacOS, Windows, and Linux (together with Chromebooks). The system comes pre-loaded with code and a few sound information. Adafruit‘s extraordinarily well-written documentation answered most of my questions. I found the unit could be programmed on Linux three alternative ways: MakeCode, the Arduino IDE, and the Python-based CircuitPython, which I selected.

Adafruit offers glorious documentation for creating and editing CircuitPython code, which I discovered useful. You can use quite a lot of editors (e.g., Emacs, Visual Studio Code, gedit), however Adafruit recommends the Mu Python editor, which I wrote about final 12 months. I installed Mu on my system with pip3 set up –user mu-editor. Then I opened a terminal and entered mu-editor. It requested me the best way to run Mu, and I selected Adafruit Circuit Python. Then I used to be in a position to have a look at the code that powers the CPX.

To open a connection between Mu and the CPX linked to your laptop, press the Serial button in Mu. Then you may see any serial knowledge from the CPX and edit it utilizing Python’s REPL shell.

Adafruit’s programmers have written a library referred to as adafruit_circuitplayground.specific that allows CircuitPython to work together with the CPX board. To use it, add import adafruit.circuitplayground.specific to your code. Or, to make it less complicated, you should use the acronym cpx, shortening the code (as proven under) to from adafruit_circuitplayground.specific import cpx.

The approach you title your file is important. The 4 choices are code.txt, code.py, most important.txt, and most important.py. CircuitPython seems to be for the code information in that order and runs the primary one it finds. Save the code to your CIRCUITPY drive every time you modify it.

The most important.py code included with a brand new CPX gives an instance of the system’s capabilities.

When you execute this code, the CPX shows stunning, brightly coloured LEDs whirling in a rainbow of colours. With my rudimentary information, I may tweak a couple of settings, like growing the brightness and turning on the TOUCH_PIANO functionality, however different modifications have been past my coding skill at this level.

Eager to do extra, I wished to seek out code snippets I may use as constructing blocks to study. First, I reached out to Nina Zakharenko on Twitter and requested for some assist. She really useful I contact Kattni Rembor, who pointed me to her GitHub repo and a few code examples she wrote for the Chicago Linux User Group.

Each of those easy constructing blocks left me extra assured in my Python journey. In addition to creating lights blink, the CPX also can perform as a sensor, and I wished to strive that. Here is code for a easy mild sensor:

And right here is the CPX with the D13 LED blinking:

I additionally found a option to create some enjoyable for my grandson by making the CPX “come to life.” I recorded a few .wav information with Audacity and saved them to the system. Then I wrote some easy code that utilized the A and B buttons on the system to make the CPX “talk” to him:

I’ve actually loved tinkering with the code to discover the CPX’s capabilities. I’m all the time in search of methods to make Python code come alive for college kids I educate. The CPX is an effective way to assist new customers study and luxuriate in coding and digital making. Another glorious useful resource for brand new customers is Mike Barela’s e book Getting Started with Adafruit Circuit Playground Express. I discovered its info and examples very useful as I used to be studying.

Get a Circuit Playground Express and begin writing your personal code. And then please share how you might be utilizing it within the feedback.

Exit mobile version