The Adafruit CLUE comes with built in buttons and a display. Using CircuitPython, the Adafruit CircuitPython CLUE and Adafruit CircuitPython Slideshow libraries, and the built in buttons and display, we can easily make an interactive slideshow.

Installing Project Code

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your CIRCUITPY drive. Then you need to update with the example script.

Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the file in a zip file. Extract the contents of the zip file, open the directory examples/clue_slideshow/ and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your CIRCUITPY drive.

Your CIRCUITPY drive should now look similar to the following image:

# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Display a series of bitmaps using the buttons to advance through the list. To use: place
supported bitmap files on your CIRCUITPY drive, then press the buttons on your CLUE to advance
through them.

Requires the Adafruit CircuitPython Slideshow library!"""

from adafruit_slideshow import SlideShow, PlayBackDirection
from adafruit_clue import clue

slideshow = SlideShow(clue.display, auto_advance=False)

while True:
    if clue.button_b:
        slideshow.direction = PlayBackDirection.FORWARD
    if clue.button_a:
        slideshow.direction = PlayBackDirection.BACKWARD

Once the code and bitmaps are loaded, try pressing button B to move forward through displaying the images, and button A to move backward through displaying the images!

Let's take a look at the code.

First we import the CLUE library and the parts of the Slideshow library we intend to use: SlideShow and PlayBackDirection.

Then we create the slideshow. To create the slideshow, you must provide it the display object (clue.display). For this example, we've also set auto_advance=False. We don't want it to auto advance because we'll be using the buttons to advance through the images.

Inside the loop, we check for when each button is pressed. When button B is pressed, we set the playback direction to FORWARD and advance one image. When button A is pressed, we set the playback direction to BACKWARD, and advance one image.

That's all there is to creating a slideshow on your Adafruit CLUE using CircuitPython!

This guide was first published on Feb 08, 2020. It was last updated on Jan 29, 2020.

This page (CLUE Slideshow) was last updated on Oct 01, 2023.

Text editor powered by tinymce.