# Creating Slideshows in CircuitPython

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/079/303/medium800/microcontrollers_pyportal.jpg?1565619990)

Pictures capture our memories, our fandom, and the world around us. But they do little good sitting on your hard drive. Grab a CircuitPython board and connected screen and display your images in a slideshow with only a few lines of CircuitPython code.

Get up and running in a few minutes. No hardware assembly and all free software.

## Parts
Featured
### Adafruit PyPortal - CircuitPython Powered Internet Display

[Adafruit PyPortal - CircuitPython Powered Internet Display](https://www.adafruit.com/product/4116)
 **PyPortal** , our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface GUIs, all open-source, and Python-powered using&nbsp;tinyJSON / APIs to get news, stock, weather, cat photos,...

In Stock
[Buy Now](https://www.adafruit.com/product/4116)
[Related Guides to the Product](https://learn.adafruit.com/products/4116/guides)
![Front view of a Adafruit PyPortal - CircuitPython Powered Internet Display with a pyportal logo image on the display. ](https://cdn-shop.adafruit.com/640x480/4116-00.jpeg)

Featured
### Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino

[Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino](https://www.adafruit.com/product/4242)
What&nbsp;fits in your pocket, is fully Open Source, and can run CircuitPython, MakeCode Arcade or Arduino games you write yourself? That's right, it's the **Adafruit PyGamer!** We wanted to make an entry-level gaming handheld for DIY gaming, and maybe a little...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4242)
[Related Guides to the Product](https://learn.adafruit.com/products/4242/guides)
![Angled shot of Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino.](https://cdn-shop.adafruit.com/640x480/4242-00.jpg)

Featured
### Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino

[Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino](https://www.adafruit.com/product/4200)
What's the size of a credit card and can run CircuitPython, MakeCode Arcade or Arduino? That's right, its the **Adafruit PyBadge!** We wanted to see how much we could cram into a ​3 3⁄8 × ​2 1⁄8 inch rounded rectangle, to make an all-in-one dev board with...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4200)
[Related Guides to the Product](https://learn.adafruit.com/products/4200/guides)
![Angled shot of a Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino. ](https://cdn-shop.adafruit.com/640x480/4200-01.jpg)

# Creating Slideshows in CircuitPython

## Setup CircuitPython

![](https://cdn-learn.adafruit.com/assets/assets/000/079/251/medium800/microcontrollers_circuitpython_circuit_playground_adafruit_blinka_computer.png?1565374722)

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) 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** &nbsp;"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!

Info: 

## Set up CircuitPython Quick Start!

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

Go to [CircuitPython.Org/Downloads](https://circuitpython.org/downloads) to find your CircuitPython compatible board.

Download the latest stable version of CircuitPython for your board. Save the .UF2 file to some known place on your computer.

Primary: 

Plug your board 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&nbsp; **Reset&nbsp;** button 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.&nbsp; **Note:** &nbsp;The little red LED may 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, ending in **BOOT** , like **PYPORTALBOOT.**

Drag the&nbsp; **adafruit-circuitpython--.uf2** &nbsp;file to the \<boardname\> **BOOT** drive **.**

The LED will flash. Then, the&nbsp; **BOOT&nbsp;** drive will disappear and a new disk drive called&nbsp; **CIRCUITPY** &nbsp;will appear.

If you haven't added any code to your board, the only file that will be present is&nbsp; **boot\_out.txt**. This is absolutely normal! That file is a text file listing the version of CircuitPython which can be handy.

It's time for you to add your&nbsp; **code.py** &nbsp;and get started!

## Issues?

See [this page](https://learn.adafruit.com/welcome-to-circuitpython/frequently-asked-questions) on FAQ with troubleshooting pages following.

# Creating Slideshows in CircuitPython

## Load the Software

![](https://cdn-learn.adafruit.com/assets/assets/000/079/300/medium800/microcontrollers_22_1023blinka_small.png?1565615828)

Your board will need two code files to work:

1. A library containing the slideshow code
2. Your program, named **code.py** , which calls the slideshow library

All of the nitty-gritty is coded in the library, making working with the code super simple.

Warning: 

## Download the Library

On the previous page you did note the version of CircuitPython you downloaded, yes?

Good. Go to [CircuitPython.Org/libraries](https://circuitpython.org/libraries) and you'll look to download the library bundle matching the major version of CircuitPython you installed.

Save the file to your computer (not on the **CIRCUITPY** drive, please).

For this project, only one library file is needed!

Ensure your board is connected to your computer via a known good USB cable. Use your operating system file explorer/finder to go to the **CIRCUITPY** drive. Create a new folder named **lib**. We'll put the library we need in this folder.

Now use your file explorer/finder to go to where you saved the library bundle zip file. Open the file and find the file named **adafruit\_slideshow.mpy**. Copy that file into the **lib** folder on the **CIRCUITPY** drive you just made. Now you're set.

## Get the Code!

The code for the project is below. Click any of the save options and save to your computer. The file you want is named **code.py** , the default run name for CircuitPython code on a CircuitPython device.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CircuitPython_Slideshow/code.py

That's it - rather short, yes? Adafruit has made the library do all the heavy lifting.

There are customizations that may be done, they will be explored after getting pictures displaying on the screen.

# Creating Slideshows in CircuitPython

## Load Your Pictures

![](https://cdn-learn.adafruit.com/assets/assets/000/079/301/medium800/microcontrollers_pyportal.jpg?1565617112)

As is, the code has no pictures on the **CIRCUITPY** drive to use in your slideshow. Let's get some.&nbsp;

While the slideshow code is short and simple, know that microcontrollers, unlike computers, don't have the greatest amount of speed and memory. So any scaling of images and conversion of graphics formats should be done on your computer before they are copied to your device.

All images must be in .bmp format. There is no specific bitmap index (1, 4, 8) for such images.

The size of the image depends on the size of your display. Here are some dimensions, if there is a board without an entry, go to the Adafruit product page to see the specifications for the display and use those.

- PyPortal - 320x240 pixels (landscape)
- PyBadge and PyBadge LC - 160x128 pixels (landscape)
- PyGamer - 160x128 pixels (landscape)
- Hallowing M0 Express - 128x128 pixels (portrait)
- Monster M4sk and HalloWing M4 Express - 240x240 pixels (square)

The image editing software available is dependent on the operating system you are using. The GNU program GIMP runs on all operating systems and is free.

In your editing software, open the image you want in the slideshow. Resize the image to the dimensions for your device. Then save the image in BMP format in a folder on your computer.

The slideshow code is set to show the pictures in alphabetical order. It is suggested you save the pictures sequentially, re. the first one is saved as 001.bmp, the second as 002.bmp, etc., this will allow for 999 images you can display in order.

Info: 

## Copying the Pictures to Your Device

In your computer's file Explorer/Finder, create a new directory on your **CIRCUITPY** drive names **images**.

Go to the folder you copied your resized BMP images into and copy the files to your **CIRCUITPY\images** directory. Once done, the device should reset and run your slideshow!

Feel free to reorder your images by changing filenames, if necessary.

## Sample Pictures

Below are sets of 6 sample pictures, formatted for the devices listed above.

What happens when you use larger images than the display resolution? You'll see as much of the picture as the display can render, say 160x128 pixels out of a larger 320x240 picture. At this time, CircuitPython cannot change the resolutions of files for display. Perhaps one day.

[BMP Image Pack in 128x128 pixels](https://cdn-learn.adafruit.com/assets/assets/000/079/304/original/128x128.zip?1565620715)
[BMP Image Pack in 160x128 pixels](https://cdn-learn.adafruit.com/assets/assets/000/079/253/original/images160.zip?1565383042)
[BMP Image Pack in 240x240 pixels](https://cdn-learn.adafruit.com/assets/assets/000/079/305/original/240x240.zip?1565633564)
[BMP Image Pack in 320x240 pixels](https://cdn-learn.adafruit.com/assets/assets/000/079/254/original/images320.zip?1565383055)
These images are from [Unsplash](https://unsplash.com/license) and come with an unlimited, free license.

[Original JPG Files from Unsplash](https://cdn-learn.adafruit.com/assets/assets/000/079/306/original/photos_from_unsplash.zip?1565633630)
# Creating Slideshows in CircuitPython

## Use It

The basic code will present a new picture each 60 seconds.

The image below has been set for 3 seconds between pictures to better show a selection of images.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/079/302/medium800thumb/microcontrollers_slideshow-demo.jpg?1565619786)

Warning: 

## Customization of the Slideshow

The **adafruit\_slideshow** library function has several parameters that can be changed. The latest documentation for parameters is on [ReadTheDocs](https://circuitpython.readthedocs.io/projects/slideshow/en/latest/api.html).

Let's look at the code again:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CircuitPython_Slideshow/code.py

 **board.DISPLAY** is common to all boards and is required. If there is an error, it probably is that your board does not have a predefined display. If you are an advanced user and hook your own display up, this will need to be defined.

**folder = "/images"** sets the image folder to the **CIRCUITPY /images** directory that we used. You can specify other directories.

**loop = True** has the images looping back to the starting image when the last image completes displaying.

**order = PlayBackOrder.ALPHABETICAL** plays the images in alphabetical order - the only other option is&nbsp;order=PlayBackOrder.RANDOM

**dwell = 60** is a parameter you may want to change. This is the amount of time a picture is on the screen in seconds. I think a minute (60 second) is a bit long, perhaps you want 30 seconds for a fast display or 3600 seconds for an hour.

For all the available parameters:

_class_`adafruit_slideshow.``SlideShow`(_display_,&nbsp;_backlight\_pwm=None_,&nbsp;_\*_,&nbsp;_folder='/'_,&nbsp;_order=0_,&nbsp;_loop=True_,  
_dwell=3_,&nbsp;_fade\_effect=True_,&nbsp;_auto\_advance=True_,&nbsp;_direction=1_)

Parameters:

- **folder** &nbsp;([_str_](https://docs.python.org/3.4/library/stdtypes.html#str "(in Python v3.4)")) – Specify the folder containing the image files, in quotes. Default is the root directory,&nbsp;`"/"`.
- **order** &nbsp;([_PlayBackOrder_](https://circuitpython.readthedocs.io/projects/slideshow/en/latest/api.html#adafruit_slideshow.PlayBackOrder "adafruit\_slideshow.PlayBackOrder")) – The order in which the images display. You can choose random (`RANDOM`) or alphabetical (`ALPHABETICAL`). Default is&nbsp;`ALPHABETICAL`.
- **loop** &nbsp;([_bool_](https://docs.python.org/3.4/library/functions.html#bool "(in Python v3.4)")) – Specify whether to loop the images or play through the list once.&nbsp;[`True`](https://docs.python.org/3.4/library/constants.html#True "(in Python v3.4)")&nbsp;if slideshow will continue to loop,&nbsp;`False`&nbsp;if it will play only once. Default is&nbsp;`True`.
- **dwell** &nbsp;([_int_](https://docs.python.org/3.4/library/functions.html#int "(in Python v3.4)")) – The number of seconds each image displays, in seconds. Default is 3.
- **fade\_effect** &nbsp;([_bool_](https://docs.python.org/3.4/library/functions.html#bool "(in Python v3.4)")) – Specify whether to include the fade effect between images.&nbsp;`True`&nbsp;tells the code to fade the backlight up and down between image display transitions.&nbsp;`False`&nbsp;maintains max brightness on the backlight between image transitions. Default is&nbsp;`True`.
- **auto\_advance** &nbsp;([_bool_](https://docs.python.org/3.4/library/functions.html#bool "(in Python v3.4)")) – Specify whether to automatically advance after dwell seconds.&nbsp;`True`&nbsp;if slideshow should auto play,&nbsp;`False`&nbsp;if you want to control advancement manually. Default is&nbsp;`True`.
- **direction** &nbsp;([_PlayBackDirection_](https://circuitpython.readthedocs.io/projects/slideshow/en/latest/api.html#adafruit_slideshow.PlayBackDirection "adafruit\_slideshow.PlayBackDirection")) – The playback direction. 1 = forward, -1 backward.


## Guide Products

### Adafruit PyPortal - CircuitPython Powered Internet Display

[Adafruit PyPortal - CircuitPython Powered Internet Display](https://www.adafruit.com/product/4116)
 **PyPortal** , our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface GUIs, all open-source, and Python-powered using&nbsp;tinyJSON / APIs to get news, stock, weather, cat photos,...

In Stock
[Buy Now](https://www.adafruit.com/product/4116)
[Related Guides to the Product](https://learn.adafruit.com/products/4116/guides)
### Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino

[Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino](https://www.adafruit.com/product/4242)
What&nbsp;fits in your pocket, is fully Open Source, and can run CircuitPython, MakeCode Arcade or Arduino games you write yourself? That's right, it's the **Adafruit PyGamer!** We wanted to make an entry-level gaming handheld for DIY gaming, and maybe a little...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4242)
[Related Guides to the Product](https://learn.adafruit.com/products/4242/guides)
### Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino

[Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino](https://www.adafruit.com/product/4200)
What's the size of a credit card and can run CircuitPython, MakeCode Arcade or Arduino? That's right, its the **Adafruit PyBadge!** We wanted to see how much we could cram into a ​3 3⁄8 × ​2 1⁄8 inch rounded rectangle, to make an all-in-one dev board with...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4200)
[Related Guides to the Product](https://learn.adafruit.com/products/4200/guides)
### Pink and Purple Braided USB A to Micro B Cable - 2 meter long

[Pink and Purple Braided USB A to Micro B Cable - 2 meter long](https://www.adafruit.com/product/4148)
This cable is&nbsp;super-fashionable&nbsp;with a woven pink and purple Blinka-like pattern!

First let's talk about the cover and over-molding. We got these in custom colors, and if you&nbsp;_have_&nbsp;to have visible cables, then you might as well have the nicest fabric-bound...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4148)
[Related Guides to the Product](https://learn.adafruit.com/products/4148/guides)

## Related Guides

- [Adafruit PyPortal - IoT for CircuitPython](https://learn.adafruit.com/adafruit-pyportal.md)
- [Adafruit PyBadge and PyBadge LC](https://learn.adafruit.com/adafruit-pybadge.md)
- [Introducing Adafruit PyGamer](https://learn.adafruit.com/adafruit-pygamer.md)
- [Game Clock with Circuit Playground & MakeCode](https://learn.adafruit.com/game-clock-with-circuit-playground-makecode.md)
- [Melting Picture Frame for PyPortal IoT images](https://learn.adafruit.com/pyportal-art-display.md)
- [PyPortal Oblique Strategies](https://learn.adafruit.com/pyportal-oblique-strategies.md)
- [PyPortal Trivia Time with the Open Trivia Database](https://learn.adafruit.com/pyportal-trivia-time-open-trivia-database.md)
- [PyPortal New New New Product Viewer](https://learn.adafruit.com/pyportal-new-new-new-product-viewer.md)
- [Pathfinder Robot Companion](https://learn.adafruit.com/pathfinder.md)
- [PyPortal Email Display with Zapier and Adafruit IO](https://learn.adafruit.com/pyportal-email-display.md)
- [PyPortal LIFX Lighting Controller ](https://learn.adafruit.com/pyportal-lifx-lighting-controller.md)
- [CircuitPython Day 2020 Countdown Clock](https://learn.adafruit.com/circuitpython-day-2020-countdown-clock.md)
- [Creating Your First Tilemap Game with CircuitPython](https://learn.adafruit.com/creating-your-first-tilemap-game-with-circuitpython.md)
- [PyPortal Philips Hue Lighting Controller](https://learn.adafruit.com/pyportal-philips-hue-lighting-controller.md)
- [Playing Animated GIF Files in CircuitPython](https://learn.adafruit.com/using-animated-gif-files-in-circuitpython.md)
- [MakeCode Arcade Pixel Animation](https://learn.adafruit.com/makecode-arcade-pixel-animation.md)
- [PyPortal View Master](https://learn.adafruit.com/pyportal-view-master.md)
