CircuitPython Setup
Your Adafruit PyPortal should already come with CircuitPython but maybe there's a new version, or you overwrote your board with Arduino code! In that case, see the below for how to reinstall or update CircuitPython. Otherwise you can skip this and proceed with the build.
Images on internal flash
The code looks for an "images" folder on the CIRCUITPY drive by default. If it can't find any there, it'll search for images on the SD card.
Images on SD Card
If no images are on the internal storage, the code will search on the microSD card. The microSD card must be FAT32 and contain a folder named "images".
Image file names can be titled arbitrarily but avoid using special characters, hyphens and the sort. Your images must be in the following format and resolution.
- Images must be 320 x 240 pixel 16-bit color .bmp files
Upload Code Files
Click the Download Project Bundle button below and save the zip file to your computer. Connect your PyPortal to your computer via a known good USB data+power cable. The PyPortal should show up as a drive in your file explorer app named CIRCUITPY.
Copy the files from the zip file to the CIRCUITPY drive.
# SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries # # SPDX-License-Identifier: MIT import os import board import busio import digitalio import storage import sdcardio from adafruit_slideshow import PlayBackOrder, SlideShow, PlayBackDirection # Default location to look is in internal memory IMAGE_DIRECTORY = "/images" switch = digitalio.DigitalInOut(board.D3) switch.direction = digitalio.Direction.INPUT switch.pull = digitalio.Pull.UP spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) try: sdcard = sdcardio.SDCard(spi, board.SD_CS) vfs = storage.VfsFat(sdcard) storage.mount(vfs, "/sd") IMAGE_DIRECTORY = "/sd/images" except OSError as error: print("No SD card, will only look on internal memory") def print_directory(path, tabs=0): for file in os.listdir(path): stats = os.stat(path + "/" + file) filesize = stats[6] isdir = stats[0] & 0x4000 if filesize < 1000: sizestr = str(filesize) + " by" elif filesize < 1000000: sizestr = "%0.1f KB" % (filesize / 1000) else: sizestr = "%0.1f MB" % (filesize / 1000000) prettyprintname = "" for _ in range(tabs): prettyprintname += " " prettyprintname += file if isdir: prettyprintname += "/" print('{0:<20} Size: {1:>6}'.format(prettyprintname, sizestr)) # recursively print directory contents if isdir: print_directory(path + "/" + file, tabs + 1) try: print_directory(IMAGE_DIRECTORY) except OSError as error: raise Exception("No images found on flash or SD Card") # Create the slideshow object that plays through once alphabetically. slideshow = SlideShow(board.DISPLAY, None, folder=IMAGE_DIRECTORY, loop=True, order=PlayBackOrder.ALPHABETICAL, dwell=0) while True: if not switch.value: print("Click!") slideshow.direction = PlayBackDirection.FORWARD slideshow.advance() while not switch.value: pass
Your CIRCUITPY drive should look like the file directory structure below:

These libraries should be on the CIRCUITPY drive lib/ directory:
- adafruit_pyportal
- adafruit_imageload
- adafruit_slideshow
- adafruit_bus_device
- neopixel.mpy
Page last edited January 22, 2025
Text editor powered by tinymce.