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.
-
What? I *can* make something PRACTICAL?!? I admit many (if not most) of my projects have virtually no "practical" applications. This is different.
My wife and I play Super Big Boggle almost every day - it's good mental exercise and a great way to exercise and expand your vocabulary. (My skill is in building up a lexicon of archaic vulgar words). (Note: said skill has not given me the edge. I usually lose ):
Now, after many hundreds of games, the little "hourglass" 3 minute egg timer has started to stick - kind of annoying when you finally notice after 4 minutes that the timer hasn't moved.
The obvious solution might be to "buy a new timer," but not for me. I've got a lot of Circuit Playground Express devices (I REALLY like the CPX!) so it made sense to me to just program a timer with the CPX, so I did.
The Makecode project is here
To use it,
- download it to your CPX
- press A to start the timer (or restart)
- press B to pause/un-pause the timer
- "Shake" the CPX to stop, clear the current timer and get it ready to start another 3 minutes
When running, a pixel blinks clockwise around the CPX, first Green, then Yellow and for the last minute Red. When it's done the "Magic Wand" sound plays.
-
How to Flash and Run CircuitPython on Your Kano Pixel Kit About the Pixel Kit
The retail Pixel Kit uses an ESP32 (The classic one) (ESP-WROOM-32) with 4MB of flash, which makes it very easy to put things like WLED, Arduino, MicroPython, and CircuitPython onto it.
Flashing CircuitPython onto Your Pixel Kit
To flash CircuitPython onto it, either use Thonny (A python editor for basically anything) or esptool (A Python-based CLI tool for ESP32)
Thonny:
- Click Tools (in bar on top)
- Select "Options..."
- Select "Interpreter"
- Click the dropdown and select CircuitPython (generic)
- Click the underlined text "esptool", this tells Thonny to flash to ESP32
- Select the COM (Windows) or dev/cu.usbmodem (Mac) (Could also be dev/tty.usbserial) port in the Target Port dropdown
- For family select ESP32 (This is what the Pixel Kit has)
- For variant select DOIT • ESP32 Development Board
- Select what CircuitPython version you want in the version dropdown
- Click Install
- Close the installer window
- Select the port for your device
- Click the stop button (Stop/Restart Backend)
- Install the necessary libraries from the bundle in their documentation. neopixel, adafruit_framebuf, adafruit_pixel_framebuf, and led_animation
- Download the CircuitPython PixelKit library from my GitHub repo (PixelKit.py) https://github.com/colinvail6/pixelkit-lib
- Install it to /lib
- Play around with the Pixel Kit!
esptool:
- Install esptool. This can be done using pip install esptool (Python 2 and lower) or pip3 install esptool (Python 3 and newer)
- Open your Terminal app (Terminal on Mac, Command Prompt on Windows, Bash on Linux)
- Erase the flash on your board. This can be done using esptool --port %PORT% --chip esp32 erase_flash (Python 2 or lower) or python -m esptool --port %PORT% --chip esp32 erase_flash (Python 3 and newer)
- Download the CircuitPython binary from https://circuitpython.org/board/doit_esp32_devkit_v1/
- Run cd Downloads
- Flash the CircuitPython binary to your Pixel Kit. This can be done using esptool --port %PORT% --chip esp32 write_flash -z 0x0 adafruit-circuitpython-doit_esp32_devkit_v1-en_US-10.0.3.bin (Python 2 or lower) or python -m esptool --port %PORT% --chip esp32 write_flash -z 0x0 adafruit-circuitpython-doit_esp32_devkit_v1-en_US-10.0.3.bin (Python 3 and newer)
- Download the CircuitPython PixelKit library from my GitHub repo (PixelKit.py) https://github.com/colinvail6/pixelkit-lib
- Install it to /lib
- Play around with the Pixel Kit!
-
LoRa Wireless Greenhouse Monitor This project uses 900 MHz RFM95W LoRa FeatherWing modules to transmit temperature measurements from greenhouses and receive them at a base station about half a kilometer away. The base station hardware outputs sensor reports over USB serial, an optional 2x16 Character LCD, and an optional ESP-NOW gateway.
The LoRa radio settings are tuned for extended battery life at a range of up to 500m in suburban or rural conditions (non line of sight with limited obstructions). With a fully charged 400 mAh LiPo battery and a 9 minute reporting interval, typical sensor runtime should be about 4 weeks (~22µA deep sleep current, ~2667ms of time per wake cycle, ~0.222 coulombs of charge per wake cycle).
To optimize the transmitter for running on a small LiPo cell, I used a Nordic nRF-PPK2 power analyzer to tune the firmware. Some of the power saving tricks I used include reducing the cpu frequency, putting the RFM95W radio in sleep mode, putting the MAX17048 fuel gauge in hibernate mode, and using ESP32-S3 deep sleep. To compare the impact of different changes, I took extensive measurements using Nordic's Power Profiler app with the PPK2 connected to the Feather board's battery jack and GPIO outputs.
Transparency note: Adafruit provided some of the parts I used for this guide (Thanks Adafruit!).
Related Projects
For logging, charting, and IRC status notifications, check out my related projects:
Overview
-
LoRa Touchscreen Pager and Tracker for Private Off-Grid Messaging About this Pager
You can build this touchscreen off-grid pager that uses LoRa and optionally GPS for location and tracking. This device lets you create (or join) a group of up to 90 devices in a private mesh network where you can send/receive messages, share location, and more.
You never know when you're going to need to be able to send messages between nearby family or friends, where cell phones don't work. You can also use these in combination with other devices (T-Deck, T-Beam, etc) and figure out where different devices are - even without having phones/internet/data. That can be really handy if you're hiking or camping in a far-out location.
How it's Built
- I designed a very simple PCB that accepts a few Adafruit components, that when combined with specialized firmware, become an off-grid communication device ready to be dropped into a 3D printed enclosure
- You can make the PCB (gerber files are included in this project) or order it from PCBWay
- The Adafruit parts are listed further down, but include Adafruit's RFM95W LoRa, 2.8" TFT Touchscreen with EYESPI & SD, Realtime Clock, FRAM, and a few other things
- After assembling these things, you'll need to flash it with firmware, which takes only a minute or so
Assembling the Pager
Here's a video demo of assembling the pager. Full detailed instructions are also available at my website:
-
IRC Display Bot A CircuitPython IRC bot for Metro ESP32-S3 to show status notifications on a small dedicated screen.
This uses a 2.8" TFT display shield to show the topic of an IRC channel in large text. Combined with a local Raspberry Pi hosted IRC server, you can use this to make a wireless status notification system for environmental sensors or whatever. Once you put the wifi and IRC server details in your settings.toml, the display will connect automatically. Then you can use any IRC bot or client you like to set the channel topic to whatever should be shown on the display. For example, I built this to work with my serial-sensor-hub project which forwards USB serial sensor reports from my lora-greenhouse-monitor sensors.
Overview
-
Building a Sci-Fi Movie Prop Overview
A local production company is working on filming the first of a three-part sci-fi movie and needed a piece of scientific equipment for a laboratory scene. The executive producer/director found an obsolete flow cytometer analyzer in a government surplus sale, winning the bid for US$12. The device had the potential to look like a working DNA synthesizer with the addition of lighting and a bit of animation.
In its day, the analyzer was a high-quality device that was robustly built to provide exceptional mechanical stability for its sensitive optical components. It was therefore quite heavy in spite of its size, requiring at least two persons to lift and position, which would increase the challenge to modify for use in the film. It was not a typical theatrical prop made from foam and balsa wood, for certain.
I was tasked with installing color lighting to enhance the device’s operational appearance for its brief appearance on-screen. To achieve this, I devised a plan to incorporate several NeoPixel LED strips, which would be controlled by a CircuitPython-based microcontroller, such as the Adafruit M4 Express Feather. The multi-colored NeoPixel LEDs could be strategically positioned both within and outside the device, thereby providing ambient illumination and symbolizing various functions, including sample loading and the incubation process.
Given that the initial device employed industrial-grade servos (specifically, three IMS MDI-17 Drive Plus Motion Control motors) for sample positioning and operating the sample fluid “sipper” needle, there was a preliminary aspiration to incorporate robotic physical movements beyond the lighting sequence. However, this objective was deferred due to the imminent project deadline, so a short puppetry cable would likely be attached to the sample positioning cam to animate movement of the test tube rack.
-
The Doctor will see you know - a chatbot nobody needs I remember being impressed when I first saw ELIZA decades ago, but also thought ... I knew people who "conversed" with less attention to what you were saying and that would be easier to program. So I did a few BASIC programs with a large set of things to say that it would put out without reference to what was typed in.
So, of course, I had to do it in CircuitPython eventually....
This is a VERY simple chatbot - originally for the neotrinkey and now in the FruitJam
Minimal "chat" with NO parsing. The doctor chooses between Nulls, Questions, Affirmations, Comments, and "Wisdom" (Asimov and Tolkien quotes) to converse with the subject. Silly, but shows how little it takes to create the illusion of sentience. You can edit the pools to your own liking.
Note: DrDroid.py will work on the neotrinkey as well, though you'll need an IDE like Mu or Thonny to run it. And delete the last line "reload()"
Create a directory in your Fruit Jam called apps/DrDroid and copy these files into it.
_ _ __| | ___ ___| |_ ___ _ __ / _` |/ _ \ / __| __/ _ \| '__| | (_| | (_) | (__| || (_) | | \__,_|\___/ \___|\__\___/|_| _ _ _ __| |_ __ ___ (_) __| | / _` | '__/ _ \| |/ _` | | (_| | | | (_) | | (_| | \__,_|_| \___/|_|\__,_| Hello, what is your name? >> mrklingon Thanks for coming by, mrklingon! This is a nice computer - I like it here. >> good to hear Have you heard not all those who wander are lost. >> Indeed What will tomorrow bring? >> I wish I knew You are good at typing! >> Thanks! Have you heard short cuts make long delays.. >> sounds familiar.... I'm getting a little tired. >> okay I'm happy you came by today. >> quit _ _ __| | ___ ___| |_ ___ _ __ / _` |/ _ \ / __| __/ _ \| '__| | (_| | (_) | (__| || (_) | | \__,_|\___/ \___|\__\___/|_| _ _ _ __| |_ __ ___ (_) __| | / _` | '__/ _ \| |/ _` | | (_| | | | (_) | | (_| | \__,_|_| \___/|_|\__,_| -
Pyboom - A game for the Fruit Jam Py-Boom
Py-Boom is a fast-paced, 8-bit-style arcade game written in CircuitPython for the Adafruit Fruit Jam and other compatible display boards.
This game is a modern take on a classic "catcher" formula, featuring both a single-player mode against an AI and a competitive two-player versus mode.
Game Modes
At the title screen, you can select your game mode:
-
1-Player Mode: You control the Bucket (P1) at the bottom of the screen. An AI-controlled Bomber moves at the top, dropping bombs at an increasing rate. Your goal is to catch as many bombs as possible to survive the level.
-
2-Player Mode: Player 1 controls the Bucket, and Player 2 controls the Bomber. P1's goal is to survive, while P2's goal is to drop bombs strategically to make P1 miss.
How to Play
P1 (Bucket) - The Catcher
-
Goal: Catch every bomb that is dropped. If you miss a bomb, you lose one of your buckets (lives). If you lose all three, the game is over.
-
Winning: If you (P1) successfully catch all bombs in a level (e.g., 10 bombs in Level 1), you win the round and advance to the next, more difficult level.
P2 (Bomber) - The Attacker
-
Goal: Make P1 miss! You have a limited number of bombs per level. Use your movement and timing to drop bombs where P1 isn't.
-
Winning: If you (P2) successfully make P1 lose all three of their buckets, you win the game!
Controls
Action
Player 1 (Bucket)
Player 2 (Bomber)
Move Left
AkeyLeft ArrowkeyMove Right
DkeyRight ArrowkeyDrop Bomb
N/A
Down ArrowkeyStart / Ready
SpacebarEnterkeyOther Controls
-
Select Mode: On the title screen, press the
1or2key. -
Restart Game: On the "Game Over" screen, press the
Rkey to return to the title screen.
Required Files
To run this game, you will need the following files on your CircuitPython device:
-
code.py: The main game code. -
The Fruit Jam OS library package.
-
pyboom.bmp: The title screen logo. -
bomb_icon.bmp: The bomb sprite icon (used in development).
Download at: Pyboom Git Hub
Background
This project was started on Microsoft Make Code for my Pygamer and was called Prison Break. With the introduction of the Fruit Jam I wanted to port this over to Circuit Python. The graphics in Make Code (MC) are saved in a TypeScript file so I had to copy the codes for the sprites over to my Circuit Python. I used the AI tools that are part of Visual Studio Code (VS) the develop functions to map the sprites maps into bitmaps and tile grids. I continued to use the AI tools to help convert the Python code from MC. I mostly used Gemini as I have 3 months of premium from purchasing my phone. Though there were times where Gemini would get stuck on fixing issues it was making so I would switch to the free tokens in VS and use Claude or Chat-GPT. I ran out of free tokens in VS and moved on to Gemini for versions 2 and 3 of the game. I am in the process of uploading my prompts that I still have access to (I lost my VS conversations :( ) and hope to have them done in the next week. I also hope to get controllers setup and maybe make paddle controllers in the future.
I found this a fun project to learn Circuit Python and coding with AI. I'm still learning the concepts of using classes and learned a lot while looking at the errors the AI was coming up with.
-
-
ASTRO - SF Starmaps for the Neotrinkey simple SF starmap creator - github repository here
I wrote this program for the neotrinkey - but will be merging it into "Traveler" a simple SF game for the Fruit Jam based on my earlier neotrinkey progam "Adventure-Engine".
Files:
- astro.py (copy to code.py}
- wise.py
- prt.py (set REPL=True for printing in REPL, False to print via HID)
- ncount.py
When you touch pad #1, produces output like:
Ahghie:3, 1 Mieas:7, 1 Syaei:1, 7 Syuuas:1, 4 Giafnk:5, 4 Zoid:7, 6 .......... ...*...*.. .......... .......... .*...*.... .......... .......*.. .*........ .......... ..........A list of stars and their x,y coordinates in a 10x10 grid, then a map of the stars.
When you touch pad #2, A random star will be picked as your "location" and the list of stars will be displayed AND the distance to each one from your current location:
location = Syuuas Ahghie:3, 1: 3.60555 Mieas:7, 1: 6.7082 Syaei:1, 7: 3.0 Syuuas:1, 4: 0.0 Giafnk:5, 4: 4.0 Zoid:7, 6: 6.32455 location = Zoid Ahghie:3, 1: 6.40312 Mieas:7, 1: 5.0 Syaei:1, 7: 6.08276 Syuuas:1, 4: 6.32455 Giafnk:5, 4: 2.82843 Zoid:7, 6: 0.0 -
Teensy 4.1 Spacemouse to Midi Bridge Here's some Arduino code for the Teensy 4.1 (Adafruit Product ID: 4622) that lets my Spacemouse Wireless from 3Dconnexion appear as a standard USB midi controller to my computer, and presumably any other USB midi hosting device. It provides six high-resolution CC pairs from the knob motion, and two on/off CC's for the two buttons.
The Teensy needs a jumper between the board Vin and the USB Host 5v pins to power the Spacemouse Dongle (unless a powered USB hub is inserted between them).
The teensy, of course, also needs to be fitted with a USB Host socket connected to the USB host pins on the board to to recieve the 3DConnexion dongle or USB wire.
The code was provided by ChatGPT after some relentless back and forth. I'm pretty clueless myself about it. But for a souless device planning to take over the world and annihilate us all, The Chatster has so far proved to be very patient and accomodating. Beyond the obviously tunable lines, the LLM should be able to adapt it more to your liking, even if your skills are as meager as my own.
-
Talking to Aliens with my Fruit Jam I have been writing, and rewriting a very simple "translator" for around 30 years. It started many years ago after getting my first copy of the Klingon Dictionary and I started experimenting with very simple programs. Not true machine translation, I just made what I called a "Universal Translator Assistant" that relexifies a language (like English) into the alien words it has matched to them. Since starting, It has kind of become my personal "hello world" program and I've written versions of this program in C, Perl, Python, BASIC, VisualBasic, CBMBasic, Javascript, Java and Scratch. And now CircuitPython
As noted, it's linguistically more than a little suspect - but it's been a fun project all the same. The languages here are Klingon, Vulcan, Mando'a and Romulan.
The github repository is here
Language sources:
- Mando'a vocab originated in Karen Traviss's Star Wars novels. For more info, see https://mandoa.org/
- tlhIingan (Klingon) vocab is a custom one I created - more official Klingon from: https://kli.org and https://hol.kag.org
- Vulcan vocab from: https://tinyurl.com/VulcanArchive - archive.org of Marketa Zvelbil's original Vulcan work.
- Romulan is from Diane Duane's Rihannsu novels, but I generated more words for use here. See also http://www.rihannsu.org/arch/www.rihan.org/drupal/lessons/introduction.html
The files should be put in apps/UTA, with the .lng files all put in a subdirectory langs.
Enter text and UTA will match English words with the Alien languages. This is not true translation, but provides vocabulary you can use to translate into the target language. It will also match Alien words back to English. Because more than one English word may map to an Alien word, the back translation may look odd.
_ _ _____ _ | | | |_ _|/ \ | | | | | | / _ \ | |_| | | |/ ___ \ \___/ |_/_/ \_\ Universal _... Translator ,' `. Assistant / \ | -._ | \ \ `._ \ \ `... `-..-`. `-._ `. _,-- `. -' '. | '.| ' loading tlhingan text: hello what is your name nuqneH nuq ghaH lIj pong text: *lang vulcan loading vulcan text: live long and prosper tich tor ang tesmur text: *help _ _ _____ _ | | | |_ _|/ \ | | | | | | / _ \ | |_| | | |/ ___ \ \___/ |_/_/ \_\ Universal Translator Assistant Help commands: *help - this file *pItlh - quit program *lang [filename] - loads langs/filename.lng Languages: vulcan, tlhingan, mandoa, romulan text: tich tor ang tesmur live long and prosper text: *lang mandoa loading mandoa text: I love you ni riduurok gar text: ni riduurok gar me love your text:You can create your own language files as NAME.lng in the langs/ directory. The format should be:
"English word", "Alien word" "English word", "Alien word" "English word", "Alien word" "English word", "Alien word" ...You would load that language with the command "*lang NAME"
-
Troubleshooting CircuitPython Programs - Beyond the Print Statement The print() function is your first debugging tool
When creating a CircuitPython program a great way to follow program flow and to examine parameters and values is to use a print() statement sending the information to the REPL. This is simple, tried and true, and you can comment them out when no longer needed to turn them off. Many this is the way to go.
Sometimes, however, you might have a lot of print statements and multiple function calls and all of the information flowing into the REPL becomes a bit hard to follow.
Making print() output easier to read
At this point one strategy to make the print outputs easier to follow is to add divider lines, line feeds, special characters, etc. For example:
Get creative and use different characters for divider lines (i.e. =, +, *). You can also combine characters such as:
-
Displaying Images on Pico Mac Emulator for Fruit Jam With my recent retro mac classic inspired enclosure project for the Fruit Jam, I got the crazy idea to display my own images on the mac emulator. Sure, you can run MacPaint, but wouldn't it be cool to display custom graphics like the Fruit Jam logo? Well, it turns out there's a bit of a process to get images to display on System 7.5, specifically on 68K architecture (which is what the pico-mac emulator is based on).
Image File Formats
JPEG, PNG and GIF images are the norm with modem day computers. But, in 1984, these image formats were not yet a thing. I thought, surely displaying a bitmap image on Mac OS System 7 shouldn't be too hard, right?
After searching google, easiest approach seemed to be: Use the Graphic Converter mac app to convert a JPEG into a MacPaint document. This however, didn't quite seem to work. When I import the converted macpaint image file into Mini vMac, it wouldn't open in MacPaint. Weird, Ok, lets try a native image file format. Again, that's not really a thing. Enter the world of the .PICT (QuickDraw picture).
-
Using the Fruit Jam Intel 286 Emulator The new 286 PC Emulator for Fruit Jam provides many interesting possibilities and a lot of fun.
This Playground Note will provide information that may not be evident or may otherwise help others.
Initial Impressions
Having wide emulation through the 80286 is helpful, through it wasn't until the '386 that memory handling got better.
I was really excited about all the display modes. But trying to get to them in DOS or QBASIC was impossible. Maybe they'll work in games but I'd like a high resolution DOS screen too.
-
Fun with Fruit Jam Neopixels The adafruit_fruitjam library makes controlling the five neopixels on the board pretty easy...
Start with the basics
We begin by initializing the library and setting things up:
[note these are code snippets only - not a complete project]
From here you can use the standard neopixel "fill" and "show" to control the neopixels altogether. To refer to the neopixel object you reference them by 'jam.neopixels' (note the s on the end) followed by the command. For example, a classic red blink would simply be: