Getting Started

Adafruit Playground is a wonderful and safe place to share your interests with Adafruit's vibrant community of makers and doers. Have a cool project you are working on? Have a bit of code that you think others will find useful? Want to show off your electronics workbench? You have come to the right place.
The goal of Adafruit Playground is to make it as simple as possible to share your work. On the Adafruit Playground users can create Notes. A note is a single-page space where you can document your topic using Adafruit's easy-to-use editor. Notes are like Guides on the Adafruit Learning System but guides are high-fidelity content curated and maintained by Adafuit. Notes are whatever you want them to be. Have fun and be kind.
Click here to learn more about Adafruit Playground and how to get started.
-
Integrating Circuit Playground Bluefruit into Home Assistant Have you always wanted to get your Circuit Playground Bluefruit working with Home Assistant? Have some Circuit Playground Bluefruit devices sitting around and you'd like to use them as temperature sensors or use the buttons to control aspects of your home?
Well, you can. Using Circuit Python and the BTHome specification for advertising data over Bluetooth, you can broadcast the temperature from a Circuit Playground over Bluetooth to your Home Assistant.
The BTHome website has a nice, quick primer on the advertisement format for BLE. An even shorter primer is here. BLE defines the format for advertisements and data packets. We're interested in the Advertisement payload format, which is part of the overall data packet.
The advertisement payload consists of a series of advertising (AD) elements. Each AD element has a length (1 byte), an ID (1 byte), followed by ad element specific data (variable length).
-
Is that a good idea? Building a one-dimensional Starfighter game.... Last January I spied an Arstechnica article, "1D Pac-Man is the best game I’ve played in 2024 (so far)", and it got me thinking. I've done more than a few little arcade games with my Pybadge - but I wondered if I could do something on the CircuitPlayground.... Hmmmm.....
So I came up with StarFighter Patrol. Basic premise: Hyperspace lanes are plagued by navigational hazards - asteroids - that you need to blast to clear for safe passage. A "lane" is a 100 element array in the program - on the CPX you see ten elements - your ship at pixel 4 or 5 (depending on which direction you are heading). The stars and asteroids move clockwise initially - the lane is a circle, if you wait long enough the same elements will come toward you.
Pressing B reverses direction, A fires your lasers. You need to clear the purple asteroids that are a hazard to hyperspace navigation. You can move to a new region by hitting A4. Or if you choose restart the game with A3. When you've been hit 5 times your score (number of asteroids cleared) will show before the game restarts. (the score is digit-by-digit, so 13 would show one pixel, then three pixels. Zero is all green pixels). In the CircuitPython version you restart when you hit A or B. The Makecode/Javascript version will restart after a pause.
The Circuit Playground display shows your spaceship as a green dot, and the stars and asteroids heading toward you in a 10 pixel-wide display - this is a portion of the 100 pixel wide hyperspace lane you patrol (think of the "lane" as a circle - you move left or right in in and will wrap all the way around if you play long enough). Your ship fires toward oncoming objects - so when you reverse course the laser blasts (yellow dots) move towards the oncoming objects.
Bonus: You can see MORE pixels if you attach https://www.adafruit.com/product/3811 - the 30 pixel Adafruit neopixel strip using A1 as the control - then you'll get a 30 pixel wide one-dimensional display!
I'm happier with the way the CircuitPython version turned out - but both versions (Makecode/Javascript or CircuitPython) pretty much work the same.
Switch to the right to turn off sound.
Files in the github archive:
- bach.py - provides musical tones - copy to Circuit Playground for starfighter.py
- starfighter.py - 1D starfighter patrol game. Destroy asteroid threats. copy to code.py on your Circuit Playground
- starfighter.js - Javascript version Makecode link: https://makecode.com/_RocF4AHbY19R
Game controls:
A - fire laser B - reverse direction A4 - hyperspace A3 - restart game A7 - show last score
-
the arm -
Hoffman Input Device using Neokey 1x4 for AAC Access Persons with disabilities related to communication may utilize grid based communication systems as Alternative Augmentative Communication (AAC). One such web based and open source system is AsTeRICS Grid developed in Vienna under government funding with the goal of making this type of communication free and accessible to all. It has a wide range of features and input methods, one of which is the Huffman input method which assigns key combinations to each cell.
This got me thinking about Adafruit's NeoKey Emoji Keyboard project and what a great fit it would be for this type of input. I managed to tweak the project's file so each key press sends the numbers 1- 4 to support navigation through the cells. Thanks to Liz Clark for the code and wonderfully helpful and easy to follow tutorial!
-
USB Host Gamepad Decoder This demonstrates a CircuitPython driver for reading XInput USB gamepad events using the Adafruit USB Host BFF (MAX3421E) and a QT Py ESP32-S3 dev board.
Demo Video
-
Home CAN Bus Network Using Telephone Wiring Have you ever wondered what you can do with your unused twisted-pair telephone wire running throughout your house? Well, how about using it as the transport medium for a CAN bus network of environmental sensors? This project, which I dubbed PhoneCAN, is a relatively easy project which uses Adafruit hardware and CiruitPython. My setup uses four CAN nodes:
- A "home" node with an OLED Featherwing display on an RP2040 CAN feather with MCP2515 CAN controller that can show current values for all four nodes using the buttons on the display
- A "send" node with ESP32-S3 Feather and CAN bus Featherwing MCP2515. This node gathers measurements from all nodes at a user-specified interval (I use 15 minutes), averages them over the interval, and pushes them to Adafruit IO.
- Two "remote" nodes which use RP2040 CAN Feathers with MCP2515 CAN controllers.
- I used two types of sensors (just because these were the ones I had on-hand) as I was interested in tracking temperature and relative humidity around my house. Any of Adafruit's environmental sensors should work:
- Gather all those old phone patch cables that you have lying around in drawers around your house (be careful though, some cables have "swapped" wiring). For most of my nodes I used RJ11 breakout boards to connect the three-wire CAN controller to my home phone jacks.
I have all of my nodes reading and posting measurements every second to the CAN bus. Documentation and sample code provided on my PhoneCAN github repository. I believe that this is a relatively easy project and was really a lot of fun to put together. Best part?.. Using that old (abandoned by the steady march of technological progress) twisted pair phone cable sitting in the walls of my house.
-
Rotary Encoder Menu System Demo This demonstrates how to add a simple menu system to your project using a single rotary encoder for input and the serial console for output.
Hardware: Parts and Tools
-
Building a "Top-Secret" lunchbox Recently I introduced my current project, which I've been calling the "Top-Secret Lunchbox", on Adafruit's Show and Tell stream. I wrote this playground to go into more detail about how I built it.
I mentioned in the stream that it took me about a week to design and build the lunchbox, but that's a pretty generous estimate that does not tell the entire story. For starters, it does not include writing any code beyond basic hardware bring-up (the game code is essentially an entire other project). It also doesn't account for the fact that this is my third attempt at such a project, building on roughly three months of prior learning and experimentation. I was able to reuse many solutions from that experience, including designs for 3D-printed panel mounts for various hardware. This allowed me to make more informed choices and reduced the amount of time needed for learning and experimentation.
The short time frame also belies that this is a fairly complex gadget for a hobbyist project. It uses most of the hardware features of the RP2040 Propmaker Feather, as well as all of the available GPIO (except for the servo output, which I did actually consider using at one point for something like a haptic motor). It required designing and printing several parts for basic assembly. It required a lot of soldering, and some "clever" solutions to some interesting challenges.
Given the overall complexity, and the fact that I was still "winging it" on several aspects of the project, this article will describe more "how I did it" than "how you should do it". I will provide as much detail as I can about the entire process, including designing, printing, wiring, and assembly. I will also provide CircuitPython source code for a full working game! You can find a walkthrough of the game at the end of this article.
-
Heat Flow Visualiser: Visualise the Invisible with NeoPixels and the RP2040 Scorpio -
Using multiple WiFi network credentials in Adafruit IO WipperSnapper firmware As of July 23rd 2024, we've added support into WipperSnapper for specifying backup wifi credentials, simply by adding an array of entries under the new key "alternative_networks" in your secrets file.
You can have up to 3 alternative/backup network configs, plus the original one. What original one? And what does it all look like? Well let's go through an example:
-
Decison Maker! An invention was patented in 1948 that has assisted millions in making decisions. Long before widespread access to computers, this device - completely mechanical gave instant answers to questions - no AI or LLM required.
I refer to ... the Magic 8 Ball.
It doesn't take much of a web search to find examples of programs to recreate the Magic 8 Ball. It's an easy exercise - for example, here's one at geeksforgeeks.org that made a fun starting point for me to adapt for some Adafruit fun.
It wasn't hard to adapt that code into CircuitPython for the NeoTrinkey. I put together Magic8.py. Load that on a NeoTrinkey - copied to code.py. When run, it will display a blinking idle pattern. Touch either touch pad and it will go to Green (yes), Yellow (maybe) or Red (no). If you are running it in an IDE like Mu or Thonny, the REPL will print an answer appropriate to the verdict. Touch the pad again to return to the idle pattern.
But, why not make a better, smarter tool - something that you can use to calculate the answer? And why not have it SPEAK the answer?
In my DecisionMaker repository you'll find all you need to do that.
Starting with MakeCode I created a two-mode DecisonMaker for Circuit Playground Express. With the switch to the right, press the "A" button and it will give you a Green/Yellow/Red verdict. In addition, IF it is plugged in to a computer with a usb cable, touching A4 will give you a verdict and TYPE the appropriate message text. (note: If the CPX is not connected to a computer, touching A4 will crash the program; also, if you copy DecisionMaker.js into MakeCode, you'll need to add the Keyboard Extension; it's already in the version at this link).
The other mode is what you get when you move the switch to the left. This lets you give more input for the program to evaluate your question. Essentially, break your question into factors (as many as you want) and give each factor a value good or bad, then ask the DecisionMaker to weigh in. With each factor press A from one to five times (for Good) and B from one to five times (for Bad). After scoring the factor, touch A1 to add it in.
For example, lets say your question is "Should I go see the new movie Super Space Blockbuster XIII?" and you break down the factors to:
- I love Super Space Blockbusters - read all the books and comics and have all the action figures
- I didn't like the last three that much
- I hear they added famous actor Kirk Handsome
- I think it will be streaming in a couple of months.
So, here's the steps in the evaluation:
Put all those together, and hit the A2 touch to get the verdict.......
-
MS-DOS Disk Images Finding Disk Images on the Internet
Bootable Disks / Operating System Disk Images
Generally it is best to make your own bootable operating system disks from media you own. Or obtain them from a company that has released them into the public domain.
FreeDOS is an open source DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded systems. Any program that works on MS-DOS should also run on FreeDOS.
MS-DOS was released by Microsoft. PC-DOS was IBM's version of MS-DOS. Note they can be different from each other. Other companies also released versions of MS-DOS licensed from Microsoft, most notably Compaq. See Wikipedia: MS-DOS. There was a competitor to MS-DOS, DR-DOS, starting in 1988 Wikipedia). Wikipedia also has a comparison of DOS operating systems as a good reference (Wikipedia). And also a timeline of DOS operating systems (Wikipedia).
A general source for operating system and application software is the Internet Archive, which has thousands of programs. Be sure to save software either in a disk image format or you may have to copy it over to a disk image (an extra, sometimes not easy, step).
Obtaining MS-DOS Disk Images
MS-DOS versions 1.25 and 2.11 have been released by Microsoft as open source under an MIT license. FreeDOS is also an open source GPL license. Other versions of DOS likely have copyright. If one has a disk image, one should have a license, usually physical media like floppy disks or a CD-ROM.
Images are being hosted on the internet, of course. It is up to the reader to do their homework as to the licensing of software they wish to obtain.
Websites with MS-DOS operating system disk images:
- A site that has MS-DOS 3 to 6: https://www.allbootdisks.com/download/dos.html (tested ok)
- A site which has DOS 1 to 7.1: https://winworldpc.com/product/ms-dos/1x (untested)
As with all software download sites, use a good antivirus / antimalware suite. For example, bootdisk.com claims they have boot disk images but they are flagged for malware by some software.
Locations to Obtain Application Disk Images
Throughout the history of MS-DOS systems, there have been numerous software licensing models. Some free, some shareware / donationware, and various commercial models. As companies went out of business, many packages became abandonware.
The licensing of non-free software is a complex subject. To that end, there are places to get disk images of vintage software.
- The Internet Archive
- https://www.goodolddays.net/diskimages/ (untested)
Information About Floppy Disks
See a comprehensive discussion by Michael Brutman: Working with Disks.
-
AIO+ Weather: A Premium Alternative for Local Observations This is the second chapter in the "Finding an openweathermap Alternative," my latest choose-an-adventure saga exploring the weather API wilderness. The first chapter, weather.gov: A Truly Free Weather API, looked at the completely-free NOAA NWS API Web Service as a replacement for openweathermap.org's API. The next area in our search is the weather power-up module of the premium (not-free but affordable) Adafruit IO Plus (AIO+) service and its CircuitPython interface.
We all know about AIO's ability to collect and display sensor data as well as its integration with messaging and control protocols such as MQTT, IFTTT, and Zapier. But did you realize that, besides increasing throughput and feed limits, AIO+ also adds SMS and Apple WeatherKit services to the mix?
My Workshop Corrosion Monitor project needs 12 AIO feeds; 5 for locally connected sensors and 7 for external weather observations. The monitor can reliably detect a corrosion condition in real time by using its attached sensors. To predict when future corrosion events may happen, the monitor needs to know what's going on with the weather outside of the workshop. Rather than installing dedicated external weather sensors (requiring holes in the wall and reliable weather-proofing), openweathermap.org's API was initially used to obtain the outside weather conditions and trends. The API was an excellent implementation up until they served notice that a credit card would be required for the "free" tier of the service. That's when I started looking for alternatives.
The large number of AIO feeds for this project had already caused me to upgrade to AIO+. At the time, I didn't realize Apple WeatherKit was included in the premium service. Now I know. Replacing the openweathermap.org API service with AIO+ weather was therefore a no-new-cost alternative for the monitor project. Besides, if I'm going to be paying for a premium service, I'd rather be sending the money to Adafruit who is committed to openly describing and supporting reliable service levels, providing tutorials, and other efforts to assure product longevity.
-
Tricorders! In 1968, I participated in my first Science Fair, and I saw a working Tricorder! It was another student's project, an assembly of different instruments for sensing things. I know it included radiation as well as temperature. It had a form of an electrical analog computer as well for calculations. It was all wrapped in a case modeled after the imaginary Tricorders on Star Trek. Pretty impressive for the time (the show was only in it's second season)!
Of course, that was a fun project that many have improved upon - there was an X Prize awarded for creating a mobile device that can "diagnose patients better than or equal to a panel of board certified physicians". And fans have constructed working props - even ones that can provide a variety of sensor readings. It's a great example of how the art of an SF program has inspired real-world engineering and development.
My own efforts are pretty modest, but it's fun to think about ways to craft a sort-of Tricorder device, given platforms like micro:bit or Circuit Playground Express with their multiple built in sensors. Early on I made a micro:bit version that displayed compass reading, light level and temperature, along with a small vocabulary of "alien" words; easy to do with the 5x5 LED matrix on the micro:bit (this was V1 micro:bit, so it didn't use the microphone). There was even an animated picture of the Enterprise.
Now, the Circuit Playground Express has good sensors but there is no graphic display, just the ring of ten neopixels - so how do you display readings? I wrote functions to display numbers by converting them to a string, and then, digit by digit, lighting up enough pixels to indicate the value. In addition, for the Circuit Python version I recorded the digits 0-9, and "point" and "minus" so I could have the device speak the number. I also think it's fun to use Morse code to display info, so for the Makecode version, I added the ability to display a number of sayings (maybe not too practical, but it was fun).
I've saved all this in a repository - here's the README
Tricorders
Code for Circuit Playground "tricorders"
- pycorder.py - "tricorder" program; toggle through idle/temp/light/gees with button A, get reading with B
- bach.py - provides musical notes, random music with touch A7, Star Wars Tune with A1
save .wav files in "digits/" directory 0.wav 1.wav 2.wav 3.wav 4.wav 5.wav 6.wav 7.wav 8.wav 9.wav gees.wav light.wav minus.wav point.wav temp.wav idle.wav
- Tricorder.js - Javascript version of CircuitPlayground Tricorder - toggle through idle/light/temp/gees/text modes with A+B, get reading with button A. when in "text" mode, tilt left/right to choose what phrase to display, press A to get morse code version
Tricorder.js
To use the Javascript code, open up https://makecode.adafruit.com start a new project, switch to Javascript mode and paste in the code. (You can also go directly to this link)
When you run the Makecode version, the program starts by blinking "hello" in Morse, then in "idle" mode, swirling a rainbow. Press A+B to jump to the next mode. Each mode shows a distinctive color:
- Light (yellow)
- Temperature (red) - note, switching the CPX switch left, gives Fahrenheit, right give Celsius
- Sound (green)
- Text (blue)
When in a sensing mode, you'll see a real time graphing of the current value - press "A" to read the current numeric value.
When you are in "text" mode, tilt left and right to choose the phrase:
0: spock = "live long and prosper"
1: yoda = "do or do not"
2: yoda2 = "size matters not"
3: yoda3 = "luminous beings are we"
4: kirk = "to boldly go"
5: picard = "engage"Press A to see the words displayed in Morse code.
CircuitPython version: pycorder.py
This requires you start with a Circuit Playground running Circuit Python (well, of course). Copy all the .wav files to a directory "digits/" and pycorder.py to code.py and bach.py on the CPX.
When it starts, it will flash a few colors, then announce "idle", going into swirling colors.
Advance modes by pressing "A" button. Again, a signal color announces the mode switch, along with a voiced "temp", "light", "gees", "idle". When in a sensing mode, press B to get the current reading.
- Temp (red) - note, switching the CPX switch left, gives Fahrenheit, right give Celsius
- Light (yellow)
- Gees (green) - note, "gees" willl announce THREE different values; the X, Y and the Z axis values
For fun, the A1 touch pad will render a Star Wars tune, and A7 will play a snatch of random tones.
-------------------------------------------------
So there you have it, my version of "Tricorder" - I'd love to see how others take that idea and make the imaginary real!
-
Virtual Display Over Web Serial This demo uses Web Serial to receive video frames from a Pi Pico and show them in a web GUI. It works like a virtual display. The video frames go over the normal CircuitPython USB serial port as base64 encoded text with start and end markers.
I developed this technique so I could have an easy way to monitor video from my PiCowbell Camera Breakout. But, this approach could probably be adapted for use as a virtual displayio display.
This uses the same hardware setup as my CamTest: PiCowbell Camera Breakout Demo project: