Introduction: Smart Picture Frame (Raspberry Pi 4)
This Instructable will walk through the process in which I built a smart picture frame with the Raspberry Pi 4. While I did not get it working on the intended screen in time, I will be detailing how to finish the project in depth. This gave me a relatively simple project I knew I was capable of doing, but because it was being programmed from the ground up, it really helped me dig deeper into Python and the Raspberry Pi's architecture.
Supplies
- Raspberry Pi 4
- 10.1 inch LCD Display for the Raspberry Pi 3/4/5
- 1x USB-to-USB-C cable
- Stands, screws, and screwdriver as included with LCD display
Step 1: Hardware Setup
This project take both minimal hardware and minimal hardware setup, which is part of the beauty of it, for me. The Raspberry Pi is simply mounted onto the back of the screen with 4 screws; There are four orange, circular slots you'll see on the center of the back of the screen, where the Pi can be screwed in. From there, highlighted #1, the provided HDMI-to-Mini-HDMI adapter, and highlighted #2, the provided USB-to-MicroUSB adapter, connect the Raspberry Pi to the screen, and provide the screen power from the Raspberry Pi itself. Meaning, all you need to connect beyond that is highlighted #3, the USB-C power cable to the Raspberry Pi itself.
Notably, once the Raspberry Pi is lined up with the mounting slots on the back, it will be very clear where the mentioned adapters plug in; there will be both a USB and a Micro-USB port, neatly adjacent to one another, as well as both an HDMI and a Mini-HDMI port. The given adapters will fit the two ports perfectly.
Step 2: Install IDE/Python
For this project, I used Visual Studio Code, and at some points, VSCodium, the Pi's built-in alternative to Visual Studio. However, any development environment program, Thonny, VSCode, SublimeText, etc. can be used. If you are developing this on the Raspberry Pi itself, like I will be in these instructions, Python will already be installed on the device. If Python is not already installed, you can install it using the following:
Step 3: Install Necessary Dependencies
To get our picture frame to work, we need some Python libraries that will allow us to create a GUI application, display an image inside that application, and animate transitions between the images.
In order to install a Python dependency, we can use the following command. This example is in the case of PyQt6, the primary library we need:
OR (to install the package globally, if necessary):
Conveniently, for the example, PyQt is the only library we need to install. Everything else we're using is built into Python. Import the libraries using the following, at the very top of a new Python file. Mine will be named init.py.
Step 4: Build the GUI Class
PyQt, the library that serves as the engine for our program, works by creating a "class", which will specify some variables and functionality that we need to be set automatically whenever a new window is made. Let's define the GUI class, which upon being initiated with the __init__ function, will set some basic information, such as the size, title, and properties of the window.
Upon initiation, we also will create a "label", which is a container in PyQt6 that houses visual elements, and we will set that label's pixmap to an image of ours. A pixmap is simply a fancy term for the containers that labels use to house images. For a label to show an image, we must set that label's pixmap.
Step 5: Add Class Functionality
Added onto the GUI class, underneath the __init__ function, we'll add a function to run a loop of our images (slideshow), detect when the escape key is pressed to exit the program, and to automatically resize the application to the full size of our working display.
Added
Step 6: Running the Program
At the end of the file, outside of the GUI class we just finished building, we'll instantiate the GUI class by making a new variable with it called window; we'll employ something called threading onto our slideshow, which simply prevents the program from crashing when we exit using the escape key, due to running multiple processes on one thread at a time; and lastly, we'll initiate the slideshow by running the slideshow thread we created, which calls our main run_loop function.
Your final product, code and running program, will look as the following on the Raspberry Pi, when ran from your IDE, or when ran from the terminal using "python3 init.py".

