Practice makes perfect when it comes to learning a musical instrument -- and sometimes you need a metronome to really drive home the tempo. In this project you'll learn how to make a metronome using the CLUE board and CircuitPython.

As a bonus, you can 3D print a classic metronome style stand for your CLUE!


These are the parts you'll need:

Adafruit CLUE - nRF52840 Express with Bluetooth LE

Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some...

USB Cable - Standard A-B

This here is your standard A-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Arduino, USBtinyISP (among other things).3 feet / 1 meter long


Little Rubber Bumper Feet - Pack of 4

Keep your electronics from going barefoot, give them little rubber feet! These small sticky bumpers are our favorite accessory for any electronic kit or device. They are sticky, but...

Looking for a PyBadge metronome? Check this one out: https://github.com/gmeader/pybadge/blob/master/metronome.py

CircuitPython on CLUE

CircuitPython is a derivative of MicroPython designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the CIRCUITPY flash drive to iterate.

The following instructions will show you how to install CircuitPython. If you've already installed CircuitPython but are looking to update it or reinstall it, the same steps work for that as well!

Set up CircuitPython Quick Start!

Follow this quick step-by-step for super-fast Python power :)

Click the link above to download the latest version of CircuitPython for the CLUE.

Download and save it to your desktop (or wherever is handy).

Plug your CLUE into your computer using a known-good USB cable.

A lot of people end up using charge-only USB cables and it is very frustrating! So make sure you have a USB cable you know is good for data sync.

Double-click the Reset button on the top (magenta arrow) on your board, and you will see the NeoPixel RGB LED (green arrow) turn green. If it turns red, check the USB cable, try another USB port, etc. Note: The little red LED next to the USB connector will pulse red. That's ok!

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

You will see a new disk drive appear called CLUEBOOT.

Drag the adafruit-circuitpython-clue-etc.uf2 file to CLUEBOOT.

The LED will flash. Then, the CLUEBOOT drive will disappear and a new disk drive called CIRCUITPY will appear.

If this is the first time you're installing CircuitPython or you're doing a completely fresh install after erasing the filesystem, you will have two files - boot_out.txt, and code.py, and one folder - lib on your CIRCUITPY drive.

If CircuitPython was already installed, the files present before reloading CircuitPython should still be present on your CIRCUITPY drive. Loading CircuitPython will not create new files if there was already a CircuitPython filesystem present.

That's it, you're done! :)

CLUE CircuitPython Libraries

The CLUE is packed full of features like a display and a ton of sensors. Now that you have CircuitPython installed on your CLUE, you'll need to install a base set of CircuitPython libraries to use the features of the board with CircuitPython.

Follow these steps to get the necessary libraries installed.

Installing CircuitPython Libraries on your CLUE

If you do not already have a lib folder on your CIRCUITPY drive, create one now.

Then, download the CircuitPython library bundle that matches your version of CircuitPython from CircuitPython.org.

The bundle downloads as a .zip file. Extract the file. Open the resulting folder.

Open the lib folder found within.

Once inside, you'll find a lengthy list of folders and .mpy files. To install a CircuitPython library, you drag the file or folder from the bundle lib folder to the lib folder on your CIRCUITPY drive.

Copy the following folders and files from the bundle lib folder to the lib folder on your CIRCUITPY drive:

  • adafruit_apds9960
  • adafruit_bmp280.mpy
  • adafruit_bus_device
  • adafruit_clue.mpy
  • adafruit_display_shapes
  • adafruit_display_text
  • adafruit_lis3mdl.mpy
  • adafruit_lsm6ds.mpy
  • adafruit_register
  • adafruit_sht31d.mpy
  • adafruit_slideshow.mpy
  • neopixel.mpy

Your lib folder should look like the image on the left. These libraries will let you run the demos in the CLUE guide.

Code the Metronome


We'll need to make sure we have these libraries installed. (Check out this link on installing libraries if needed.)

  • adafruit_apds9960
  • adafruit_bmp280.mpy
  • adafruit_bus_device
  • adafruit_clue.mpy
  • adafruit_display_shapes
  • adafruit_display_text
  • adafruit_lis3mdl.mpy
  • adafruit_lsm6ds.mpy
  • adafruit_register
  • adafruit_sht31d.mpy
  • neopixel.mpy
  • simpleio.mpy

Text Editor

Adafruit recommends using the Mu editor for editing your CircuitPython code. You can get more info in this guide.

Alternatively, you can use any text editor that saves files.


Copy the code from the code-block below and paste it into the Mu editor and save it to your CLUE as code.py (or copy code.py from the zip file and place on the CIRCUITPY drive).

import time
import board
import displayio
import terminalio
import simpleio
from adafruit_display_text import label
from adafruit_display_shapes.rect import Rect
from adafruit_clue import clue

blink_light = True  # optional flashing backlight on accent
tempo = 120  # in bpm
print("BPM: {}".format(tempo))
time_signature = 4  # Beats per measure
delay = 60 / tempo

clue.display.brightness = 1.0
clue.pixel.brightness = 0.2
screen = displayio.Group(max_size=11)
TEAL = 0x009E98
LT_TEAL = 0x000F0F
GRAY = 0x02403E
BLACK = 0x000000

clue.pixel.fill(0)  # Turn off the pixel

# Setup screen
# BG
color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = TEAL
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette)

# title box
title_box = Rect(0, 0, 240, 60, fill=GRAY, outline=None)

# title text
title_label = label.Label(
    terminalio.FONT, text="Metronome", scale=4, color=TEAL, max_glyphs=11
title_label.x = 14
title_label.y = 26

# interval text
interval_label = label.Label(
    terminalio.FONT, text=("{} BPM".format(tempo)), scale=5, color=WHITE, max_glyphs=7
interval_label.x = 20
interval_label.y = 95

# mid line
mid_line = Rect(0, 134, 240, 3, fill=GRAY, outline=None)

# vert line
vert_line = Rect(117, 134, 3, 56, fill=GRAY, outline=None)

# Signature text
sig_label = label.Label(
sig_label.x = 30
sig_label.y = 160

# play text
play_label = label.Label(
    terminalio.FONT, text=(" play"), scale=3, color=BLACK, max_glyphs=5
play_label.x = 138
play_label.y = 160

# footer line
footer_line = Rect(0, 190, 240, 3, fill=GRAY, outline=None)

# increment label
increment_label = label.Label(
    terminalio.FONT, text=("-1  +1"), scale=3, color=GRAY, max_glyphs=8
increment_label.x = 3
increment_label.y = 220

# show the screen

def metronome(accent):  # Play metronome sound and flash display
    clue.display.brightness = 0.5  # Dim the display slightly
    if accent == 1:  # Put emphasis on downbeat
        if blink_light:
            clue.pixel.fill(YELLOW)  # Flash the pixel
        simpleio.tone(board.SPEAKER, 1800, BEEP_DURATION)
    else:  # All the other beats in the measure
        if blink_light:
            clue.pixel.fill(LT_TEAL)  # Flash the pixel
        simpleio.tone(board.SPEAKER, 1200, BEEP_DURATION)
    if blink_light:
        clue.pixel.fill(0)  # Turn off the pixel
    clue.display.brightness = 1.0  # Restore display to normal brightness

tempo_increment = 1  # increment for tempo value setting
feedback_mode = 0  # 0 is sound and visual, 1 is sound only, 2 is visual only
running = False

t0 = time.monotonic()  # set start time

while True:

    # play/pause
    if clue.button_b:
        if play_label.text == " play":
            play_label.text = "pause"
            play_label.text = " play"
        running = not running
        beat = 1  # start with downbeat

    # Time Signature change
    if clue.button_a:
        print("sig change")
        if time_signature == 4:
            time_signature = 3
            time_signature = 4
        sig_label.text = "{}/4".format(time_signature)
        beat = 1  # start with downbeat

    if running and (time.monotonic() - t0) >= delay:
        t0 = time.monotonic()  # reset time before click to maintain accuracy
        beat = beat - 1
        if beat == 0:  # if the downbeat was just played, start at top of measure
            beat = time_signature

    # tempo changes
    if clue.touch_0:
        if tempo_increment is 1:
            tempo_increment = 10
            increment_label.text = "-10 +10"
            tempo_increment = 1
            increment_label.text = "-1  +1"
        time.sleep(0.2)  # debounce

    if clue.touch_1:
        if tempo > 40:
            tempo = tempo - tempo_increment
            delay = 60 / tempo
            interval_label.text = "{} BPM".format(tempo)
            time.sleep(0.2)  # debounce

    if clue.touch_2:
        if tempo < 330:
            tempo = tempo + tempo_increment
            delay = 60 / tempo
            interval_label.text = "{} BPM".format(tempo)
            time.sleep(0.2)  # debounce

How to Use the CLUE Metronome

  • Press B button to play/pause
  • Press A button to switch time signatures
  • Press touch pad #0 to switch BPM adjustment increments
  • Press touch pads #1 or #2 to decrease or increase tempo

3D Print the Metronome Stand

Download the .stl files and print the parts using PLE at 0.2mm layer height, no support needed.

The bottom cover won't be necessary.


Place the CLUE into the case back and then snap-fit the front cover into place.

Push the CLUE in its case into the stand face until the front plate is just proud of the surface.

You can optionally add a bead of CA glue along the back edges for a more secure fit.

To prevent sliding, adhere three rubber bumper feet to the underside of the base.

Set the face plate and CLUE into the base as shown.

This guide was first published on May 09, 2020. It was last updated on May 09, 2020.