There are two ways to load haikus on your MagTag. Write them in a local text file haikus.txt and put the file on the CIRCUITPY drive, or create a "haikus" feed on Adafruit IO and add them to feed. Depending on where you display your MagTag and how you power it, one or the other may be more convenient.
The code compiles the full list of haikus from both places so you can use either one or mix it up with some of each.
The right and left buttons, labeled D11 and D15, will cycle through the list of available haikus moving to the next or previous one to show it on the display.
The down button, labeled D12, will select a different random haiku from the list and change to it.
Local haikus.txt file
The first way to load haikus is to put them in a text file named haikus.txt in the root of the CIRCUITPY drive. If you downloaded the project bundle includes a haikus.txt with a handful of electronics and coding themed haikus. The format of the file is fairly simple with each 3-line haiku being separated by a full blank line, see the truncated example below.
hot iron, cool bench everything is organized nirvana achieved continuity? the multimeter goes beep testing continues rainbow LEDs blink and chase and undulate example code.py
Add your favorite haikus to the file by making new lines at the bottom or inserted between the existing ones. Or you can start from a blank file and write your haikus using the same syntax if you don't want to use the ones that come with the project bundle.
The other option is to set up an Adafruit IO Feed named "Haikus" and then add each haiku as an entry in the feed.
In order to load haikus from Adafruit IO, you must follow the steps on the Create Your settings.toml page. You need to have all of: CIRCUITPY_WIFI_SSID, CIRCUITPY_WIFI_PASSWORD, ADAFRUIT_AIO_USERNAME, and ADAFRUIT_AIO_KEY in settings.toml with appropriate values for your WiFi network and AIO access.
Log in to Adafruit IO, click on "Feeds" in the navigation links then click on the "New Feed" button.
Enter the name "Haikus" for the new feed then press the Create button. The project code uses the feed name to fetch data so it is important to use the exact name "Haikus" or else it will not find the correct feed.
After the feed is created, click on its name in the list of feeds to go to the page for the new feed.
Click on the "Add Data" button to create a new entry in the feed.
Type or paste the lines of the haiku with \n in between each line. You must include the newline escape sequence \n in the haiku in order to get the lines to wrap at the appropriate points when displayed on the MagTag. For example:
The keyboard goes clack\nwriting code at 3AM\ntime for espresso!
Once a haiku with appropriate newline escapes is entered, press the "Create" button.
Repeat the process to add as many haikus as you want.
The project code will fetch the data from this feed and add the haikus from it to the list to be shown by the app.
Page last edited January 26, 2026
Text editor powered by tinymce.