A maze generation and solving application for the Pimoroni Presto device. This project creates random mazes, displays them on the Presto screen, and animates the solving process.
This application uses a depth-first search algorithm to generate random mazes and then solves them using a pathfinding algorithm. The maze is displayed on the Presto's screen with a clock shown in the top-right corner.
The main application file containing the core functionality:
-
MazeGenerator: Creates random mazes using a depth-first search algorithm
- Generates a maze with walls and paths
- Creates an empty space in the top-right corner for displaying a clock
- Sets start and goal positions
-
MazeSolver: Solves the generated maze
- Uses a pathfinding algorithm to find a route from start to goal
- Animates the solving process on the display
- Tracks visited cells and the final solution path
-
MazeDisplay: Handles all display-related functions
- Draws the maze on the Presto screen
- Shows the clock in the top-right corner
- Provides visual feedback during maze solving
- Animates the solution path
-
Main Function: Controls the program flow
- Generates a new maze
- Displays the maze
- Solves the maze
- Animates the solution
- Waits for a specified time before generating a new maze
Configuration settings for the application:
GMT_OFFSET: Time zone offset (default: 9 for Tokyo)MAZE_WIDTH: Width of the maze (default: 19)MAZE_HEIGHT: Height of the maze (default: 19)HAS_WIFI: Flag to enable/disable WiFi connection (default: True)NEXT_SLEEP: Time to wait before generating a new maze (default: 6 seconds)
- Random Maze Generation: Creates unique mazes each time
- Interactive Display: Touch the screen to change maze size (19×19, 33×33, 79×79, 119×119)
- Real-time Clock: Displays current time in the top-right corner with automatic synchronization via WiFi
- Animated Solving: Visualizes the maze-solving process
- Configurable Settings: Easily adjust maze size, time zone, and other parameters
-
Prepare your Pimoroni Presto device:
- Make sure your Presto device has MicroPython installed with the Presto library
- Connect your Presto device to your computer via USB
-
Configure WiFi and settings:
- Open
config.pyin a text editor - Set your local time zone by adjusting
GMT_OFFSET(default: 9 for Tokyo) - Adjust maze dimensions with
MAZE_WIDTHandMAZE_HEIGHTif desired - Set
HAS_WIFItoTrueif you want to use WiFi for time synchronization - Modify
NEXT_SLEEPto change the wait time between maze generations
- Open
-
Upload files to your Presto device:
- Open Thonny IDE
- Connect to your Presto device
- Upload both
main.pyandconfig.pyto the root directory of your Presto device - Make sure both files are saved with their exact names
-
Run the application:
- The application will start automatically when the Presto device boots
- Alternatively, you can run it manually by executing
main.pyin Thonny
- Once the files are uploaded to your Pimoroni Presto device, the application will start automatically
- The device will connect to WiFi (if
HAS_WIFIis set toTrue) to synchronize time - Touch the screen to cycle through different maze sizes (19×19, 33×33, 79×79, 119×119):
- Each touch will switch to the next size in sequence
- The maze will be regenerated with the new size immediately
- Larger mazes are more complex and take longer to solve
- The application will generate, solve, and display new mazes continuously
- The current time will be displayed in the top-right corner of the screen:
- Time is automatically synchronized via WiFi (if enabled)
- The clock continues to update even during maze generation and solving
- Pimoroni Presto device
- MicroPython with the Presto library
- WiFi connection (for time synchronization, optional if
HAS_WIFIis set toFalse)
You can customize the application by modifying the config.py file:
-
Time Zone: Set your local time zone with
GMT_OFFSET(default: 9 for Tokyo)# Example: Set to London time (GMT+0) GMT_OFFSET = 0
-
Maze Dimensions: Change the maze size by adjusting
MAZE_WIDTHandMAZE_HEIGHT# Example: Create a larger maze MAZE_WIDTH = 33 MAZE_HEIGHT = 33
Note: The application supports sizes 19×19, 33×33, 79×79, and 119×119, which can be cycled through by touching the screen
-
WiFi Connection: Enable or disable WiFi for time synchronization
# Example: Disable WiFi connection HAS_WIFI = False
-
Wait Time: Adjust the wait time between maze generations with
NEXT_SLEEP# Example: Wait 10 seconds between mazes NEXT_SLEEP = 10
All changes to config.py take effect after restarting the Presto device or rerunning the application.
