This is the basic version of the code. You set predefined message text and heart colors. Then, you can cycle through them using either of the buttons on the Circuit Playground Bluefruit.

Connect your Circuit Playground Bluefruit to your computer via a known good data USB cable. The board should show up in your operating system file explorer/finder as a flash drive named CIRCUITPY. Time to copy over some files for this project.


First, make sure you have these libraries copied over to the board following this guide page:

Make sure you have at least version 2.2.0 of the Adafruit Display Text library.


Here's the code for the basic version. We'll go in to more detail about how it works in the following pages.

This code uses a custom font file and a BMP file for the heart image. To get those as well as the code, click the Project Zip link in the embedded code listing below. This will download all the files you need at once.

In addition to the code, be sure to copy the Multicolore_36.bdf and heart_bw.bmp file to you CIRCUITPY folder.

# SPDX-FileCopyrightText: 2020 Carter Nelson for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
from random import choice
import displayio
import adafruit_imageload
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label
from adafruit_gizmo import tft_gizmo
from adafruit_circuitplayground import cp

#---| User Config |--------------------------------------------------
    ("I LUV", "YOU"),
    ("SAY", "YES"),
    ("HUG", "ME"),
    ("BE", "MINE"),
    0xEAFF50, # yellow
    0xFFAD50, # orange
    0x9D50FF, # purple
    0x13B0FE, # blue
    0xABFF96, # green
    0xFF96FF, # pink
    0xFF0000, # red
#---| User Config |--------------------------------------------------

# Create the TFT Gizmo display
display = tft_gizmo.TFT_Gizmo()

# Load the candy heart BMP
bitmap, palette = adafruit_imageload.load("/images/heart_bw.bmp",

heart = displayio.TileGrid(bitmap, pixel_shader=palette)

# Set up message text
font = bitmap_font.load_font("/fonts/Multicolore_36.bdf")
line1 = label.Label(font, text="?"*9)
line2 = label.Label(font, text="?"*5)
line1.anchor_point = (0.5, 0)    # middle top
line2.anchor_point = (0.5, 1.0)  # middle bottom

# Set up group and add to display
group = displayio.Group()
display.root_group = group

while True:
    # turn off auto refresh while we change some things
    display.auto_refresh = False
    # pick a random message
    line1.text, line2.text = choice(HEART_MESSAGES)
    # update location for new text bounds
    line1.anchored_position = (120, 85)
    line2.anchored_position = (120, 175)
    # pick a random text color
    line1.color = line2.color = choice(MESSAGE_COLORS)
    # pick a random heart color
    palette[1] = choice(HEART_COLORS)
    # OK, now turn auto refresh back on to display
    display.auto_refresh = True
    # wait for button press
    while not cp.button_a and not cp.button_b:
    # just a little debounce
Be sure you click the "Download Project Zip" link to get all the files and not just the code. You'll get the heart bitmap and the font file too.

This guide was first published on Feb 09, 2020. It was last updated on Jun 13, 2024.

This page (Basic Code) was last updated on Jun 13, 2024.

Text editor powered by tinymce.