Skip to the content
2 layers101.6 × 123.8 mmMicromouse final, the printed circuit board in 3D

Micromouse final

Vatsal314/Micromouse1

Autonomous maze-solving robot using STM32F411, Flood Fill, VL53L0X ToF sensors, and N20 encoder motors.

Size
101.6 × 123.8 mm
Copper layers
2
Thickness
1.6 mm
Parts
14
Nets
53
Pads
153
Tracks, vias
242, 10
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
12 Jul 2026
Updated
13 Jul 2026

Overview

Micromouse final is an open-source printed circuit board by Vatsal314, from the Vatsal314/Micromouse repository on GitHub. It is a 2-layer board of 101.6 × 123.8 mm with 14 parts on 53 nets, routed with 242 tracks and 10 vias.

It belongs with the robots and motor control and sensors and measurement boards of this library.

README

README.md

MicroMouse: Autonomous Maze-Solving Robot

An autonomous, self-navigating maze-solving robot designed to map, compute, and solve a grid using the Flood Fill algorithm. The system features a custom-designed PCB to streamline power and sensing, coupled with real-time sensor feedback over standard serial protocols.

Tech Stack & Hardware Components

  • Microcontroller: STM32F411CEU6 "Black Pill" (ARM Cortex-M4)
  • Core Algorithm: Flood Fill (Maze mapping, cell weight updates, and path optimization)
  • Sensing & Telemetry:
    • VL53L0X Time-of-Flight (ToF) sensors for precise distance/wall detection
    • MPU6050 Gyroscope/Accelerometer for straight-line stabilization and precise turns
  • Actuation & Control:
    • 12V 1000RPM N20 Encoder Motors for closed-loop speed control
    • TB6612FNG Dual Motor Driver
  • Power Management: 11.1V LiPo battery pack with onboard regulation for logic and motor rails
  • Design Tools: KiCad (Schematics & PCB Layout)

Firmware & Logic Implementation

  • Maze Solving: Implements a dynamic Flood Fill matrix routine that updates cell values on the fly as the mouse discovers walls.
  • Hardware Integration: Configured SPI/I2C buses to communicate with peripheral sensors and motor drivers, ensuring low-latency feedback loops for precise alignment.

Hardware Architecture & PCB Design

To minimize structural footprint and eliminate complex wiring failure points, a custom multi-layer PCB was fabricated.

  • Power Management: Dedicated onboard regulation filtering out 12V motor noise from the sensitive 3.3V STM32 logic lines.
  • Sensor Alignment: Precise angled placement for the VL53L0X ToF sensors to map front and side clearances accurately.

Maze Description

The robot was tested and validated in a physical maze environment configured with the following specifications:

  • Dimensions and Grid: A modular grid layout featuring distinct pathways, vertical wall dividers, and an enclosed central target zone.

  • Physical Construction: Built using white foam board panels for the structural walls and a gridded base layer featuring blue alignment markings to delineate cell thresholds.

  • Core Objective: The robot starts from the outer perimeter and relies on real-time sensory feedback to dynamically map cell paths, track orientation changes, and navigate toward the centralized goal area.

Algorithm & Firmware Implementation

The robot utilizes a dynamic Flood Fill algorithm optimized for real-time maze-mapping, tracking orientation updates, path optimization, and execute routines.

1. Maze Initialization (Flood Fill Array)

  • Manhattan Distance Matrix: At startup, the initFloodfill routine populates the arena_map grid using Manhattan distance bounds calculated relative to the target cell coordinate (0, length - 1). Every cell is given an initial cost matrix weight indicating its theoretical steps away from the destination.
  • Perimeter Boundary Flagging: The initWalls function instantiates the initial maze boundary configuration, defaulting the grid's outer boundary elements to closed parameters.

2. Sensor Polling & Real-Time Mapping

  • Dynamic Wall Updating: During runtime execution loop, the robot polls data from the left, right, and center VL53L0X Time-of-Flight (ToF) sensors. If an obstacle distance drops below detectDist (180 mm), the corresponding coordinate index within the global wall_data matrix is permanently flagged (= 1).
  • Orientation-Aware Bitmasking: The code tracks the absolute heading (facing variable mapping to 0: West, 1: North, 2: East, 3: South). Relative ToF configurations (Left, Front, Right) are translated into absolute compass coordinates to ensure accurate wall updates as the orientation shifts.

3. Queue-Driven Map Restructuring (rearrange_map)

  • Dead-End Discovery: If the robot discovers new walls that make its current cell value equal to or lower than all accessible adjacent neighbors, the rearrange_map routine initiates.
  • BFS Flood Refresh: The cell coordinate is pushed onto a custom Queue structure. The program continuously pops elements from the queue, calculating the minimum accessible neighbor via minimum_value_accessible_neighbors. The cell value is updated dynamically to smallest_neighbor_value + 1, and all unblocked adjacent neighbors are placed into the queue to recursively refresh the local routing map.

4. Navigation & Path Optimization

  • Compass to Action Translation: The system determines optimal cell transitions through the direction_wrt_bot routine. It converts required compass steps into actual motion commands (moveForward, TurnLeft, TurnRight, Turn180).
  • Stack-Based Path Reduction: As the mouse explores the maze, it tracks steps sequentially inside path_taken. Dead ends or backtracks are parsed by reduceDirections, which processes the path string through a custom stack interface to discard inverse direction pairings (e.g., North-South or East-West cancellations). This converts the discovery track into a clean tracking coordinate sequence saved into short_path.

5. Acceleration-Optimized Final Run (final_run)

  • After mapping out the optimal trajectory, the system executes a localized final straightaway acceleration routine via final_run.
  • Instead of stopping at every single node intersection, the algorithm aggregates sequential straight moves (steps++). If sequential cells follow a uniform direction, it executes long-distance acceleration (moveForward(steps * steplength * 0.9)) coupled with tuned PD constants (KP_WALL, KD_WALL, KP_YAW), leveraging the N20 encoders for high-speed transit.

Hardware Design & PCB Layout

Schematic Capture

PCB Layout & Routing

Note on Hardware Evolution: This custom multi-layer PCB was originally architected and routed around a Teensy 4.1 MCU footprint. The subsequent physical implementation and final firmware integration were ported to the STM32F411CEU6 "Black Pill" microcontroller to align with specific processing, layout, and peripheral subsystem constraints.

Parts

14
QtyValueFootprintReferences
3VL53L0X TOFSensor_TOF:TOF sensorTOF_1, TOF_2, TOF_3
2~Teensy 4.1:Teensy headersU2, U7
1LOGOLOGOG***
1MPU-6050 GYROMPU-6050:MPU6050U8
1Motor_Encoder_1Motor_N20:EncoderM1
1Motor_Encoder_2Motor_N20:EncoderM2
1Tb6612FNGMOTOR_DRIVERS:TB6612FNGU1
1~Switch_SPDT:SPDT_micromouseU6
1~Connector_AMASS:AMASS_XT60-F_1x02_P7.20mm_VerticalU4
1~BUCK:BUCKU3
1~Teensy_Boards:Teensy_4.1U5

Similar boards

  • 2 layers116.8 × 30 mmType d, the printed circuit board in 3D

    Type d

    google/mozc-devices

    Circuit diagrams and firmware source code for Gboard DIY keyboards

    14 parts3kApache-2.0
  • 2 layers32 × 22 mmDiff driver, the printed circuit board in 3D

    Diff driver

    rene-dev/stmbl

    AC Servo Driver for STM32F4

    14 parts990GPL-3.0
  • 2 layers34 × 45 mm2032Charger, the printed circuit board in 3D

    2032Charger

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    14 parts915
  • 2 layers34 × 109.9 mmTdisplay s3, the printed circuit board in 3D

    Tdisplay s3

    landonr/homeThing

    Wifi Smart Home Remotes that run on ESPHome

    14 parts551GPL-3.0
  • 2 layers45.3 × 42.7 mmMainPcb, the printed circuit board in 3D

    MainPcb

    adamb314/ServoProject

    Getting the most out of your hobby servo

    14 parts545
  • 2 layers42.5 × 28.8 mmC5VRX JACK DIY, the printed circuit board in 3D

    C5VRX JACK DIY

    Twotoz/C5VRX

    Ultra-minimal, zero-CPU 5.8 GHz analog FPV video receiver using ESP32-C5 Wi-Fi 6 PHY MODEM_DIAG, BitScrambler WBFM demodulation & resistor DAC CVBS

    14 parts515GPL-3.0
  • 2 layers62 × 24 mmMai button, the printed circuit board in 3D

    Mai button

    whowechina/mai_pico

    Pico controller for Maimai

    14 parts475

Questions

How big is the Micromouse final PCB?

It measures 101.6 × 123.8 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Micromouse final use?

14 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Micromouse final KiCad files?

From the Vatsal314/Micromouse repository on GitHub, at the commit this page was made from: the board is PCB Design Files/Micromouse_final.kicad_pcb and its schematic PCB Design Files/Micromouse_final.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Micromouse final design in my own project?

Its repository states no licence, so its author keeps all rights: ask Vatsal314 before reusing the design.