Skip to the content
4 layers142.3 × 80.5 mmFinal Version, the printed circuit board in 3D

ECNG 4504 (AUC, Spring 2026): autonomous maze-learning & solving robot — MCU (Arduino), Python BLE host app, KiCAD/docs, team deliverables. Single monorepo per course charter.

Size
142.3 × 80.5 mm
Copper layers
4
Thickness
1.6 mm
Parts
99
Nets
150
Pads
401
Tracks, vias
1,012, 137
Pours
5
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
16 Apr 2026
Updated
15 May 2026

Overview

Final Version is an open-source printed circuit board by elshazlio, from the elshazlio/ecng4504-maze-solver_team_5 repository on GitHub, published under the MIT licence. It is a 4-layer board of 142.3 × 80.5 mm with 99 parts on 150 nets, routed with 1,012 tracks and 137 vias.

It is built around the ATMEGA2560-16AU, CC2540F256RHAR and L298N, with the TCRT5000, AMS1117-3.3 and AMS1117-5.0 among its other parts. Its parts include 41 capacitors, 21 resistors, 15 diodes, 11 ICs and 4 inductors. It belongs with the radio and wireless and robots and motor control boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

7

README

README.md

ECNG 4504 — Autonomous maze-learning & maze-solving robot

American University in Cairo · School of Sciences and Engineering
ECNG 4504 — Embedded Systems for Wireless Communications · Spring 2026


Abstract

This project is an autonomous line-following robot that learns an unknown maze in a training pass and later executes a shortened turn sequence to reach the goal efficiently. A PC host connects over Bluetooth (BLE with HM-10, or Bluetooth Classic SPP with a ZS-040 / HC-05) to issue commands, stream status, and visualize behavior. On-robot software is a single Arduino sketch (working_code.ino) built around discrete line following (no PID), left-hand-rule decisions at intersections, in-place path simplification, and EEPROM persistence of the optimized path.


How we approached the project

We treated the work as a loop of measure → interpret → act → log, repeated until the vehicle behaved reliably on real tape and real junction geometry.

  1. Hardware and sensing
    We brought up five reflective sensors (left-to-right array), differential drive via motor drivers, and wireless UART on Serial1 (HM-10 BLE or ZS-040 / HC-05 classic) so the laptop could see the same telemetry as USB debug.

  2. Baseline motion
    Before worrying about mapping, we stabilized line following using fixed PWM steps and simple rules from the sensor pattern (centered forward, soft correct near center, stronger correct when the line moves under an outer sensor). This deliberately avoids PID tuning loops in favor of predictable, repeatable motion on our course.

  3. Seeing intersections
    Real junctions rarely match ideal drawings: wide tape, gaps, and noise meant “all black” or “wide center” could mean different things. We added timing and lockouts (NODE_LOCKOUT_MS) so the robot did not re-trigger the same junction, and short probe moves with burst sampling across the array to classify left / straight / right exits when possible.

  4. Training as a path string
    During training, at each real decision node the robot applies the left-hand rule: prefer L, then S, then R. The sequence of taken turns is appended to a raw path (L, S, R, or B for dead-end / U-turn). Dead ends are detected when the line is lost for long enough and recovered with a U-turn and a recorded B.

  5. When geometry is ambiguous
    For multi-exit junctions, recording is deferred briefly: after the turn, the firmware accumulates “witness” from the outer sensors and scores candidate exit masks so the stored junction record matches what the robot actually saw after committing to a turn.

  6. Optimizing the remembered path
    After training, the firmware folds the raw path: any middle B (dead-end) with neighbors is combined using turn angles (90° increments) so backtracking detours collapse into a single equivalent turn. That yields the optimal path string used in solve mode.

  7. Solve mode
    In solving, the robot walks the optimized sequence: at each true decision node it executes the next character of optimalPath. If sensor classification and the stored path disagree, it logs a mismatch and falls back to the left-hand choice so the run degrades safely.

  8. Host software
    We built a FastAPI dashboard with WebSockets (Bluetooth stuff/maze_dashboard/) — Bleak for BLE, or pyserial to a paired Bluetooth SPP serial port on macOS — plus a small Bun log viewer (Bluetooth stuff/log-viewer/) to command TRAIN / START, watch logs, and debug link issues.

Diagrams in this repo: high-level software structure is in system_architecture.png; the PCB is exported as [PCB Schematic.png](PCB Schematic.png). Team and roles are in team.md.


Firmware: theory and implementation

The firmware implements a maze-learning pipeline that is graph-free on the MCU: the map is a string of turns, not an explicit adjacency list. That matches the course emphasis on embedded constraints and clear state machines.

Line following without PID

Line tracking uses rule-based steering (followLineNoPID): the center sensor defines “on track,” left/right pairs request differential spins at tuned speeds (BASE_SPEED, TURN_SPEED, ALIGN_SPEED, etc.). There is no PID controller—the design trades fine continuous control for bounded behavior that is easier to reason about on inconsistent surfaces. After turns, alignToCenterStrict recenters on a center-only pattern before moving forward.

Junction detection and training probes

A node candidate is inferred from reflective patterns (nodeCandidateNow): e.g. all sensors on line (wide intersection) or outer sensors with inner body. After a lockout window, the robot stops and runs inspectAndHandleNodeTraining: short forward motion samples bursts of left/right/straight visibility to set exit masks (bits for L, S, R). The left-hand rule (selectTurn) chooses the physical turn. Finish is a sustained all-black region confirmed as the end box (confirmEndBox).

Recording and deferred resolution

For junctions with multiple plausible exits, the firmware may defer committing the recorded mask (finalizePendingTrainingRecord, RECORD_RESOLVE_MS) so post-turn sensor witnesses improve which mask is stored with the segment time. Single-exit corridors force a turn without the same ambiguity.

Path optimization (dead-end folding)

The raw training path includes detours. buildOptimalPath repeatedly replaces triples where the middle turn is B by summing turn angles (L = 270°, S = 0°, R = 90°, B = 180°) and mapping the result back to a single letter. This removes redundant out-and-back structure while preserving net heading.

Solving

Solve mode (inspectAndHandleNodeSolving) indexes optimalPath with solveStepIndex. Only at true decision nodes (multiple exits, or zero exits) does it consume the next stored turn; forced corridors follow the obvious exit. EEPROM (EepromMazeData) can persist raw and optimized paths across power cycles (LOAD, CLEAR, auto-load on boot).

Commands and telemetry

USB and wireless UART share the same command set (TRAIN, START/SOLVE, STATUS, DUMP, LOAD, CLEAR, STOP). Status lines (STATE, STAGE, paths, node logs) go to both streams for the dashboard and debugging.


Repository contents

DeliverableLocation
MCU firmware (final)working_code.ino
Backend (FastAPI, BLE, WebSockets)Bluetooth stuff/maze_dashboard/
Web UI (log viewer)Bluetooth stuff/log-viewer/
BLE helper scriptsBluetooth stuff/ble_log_receiver.py, Bluetooth stuff/ble_scan.py, Bluetooth stuff/requirements.txt
Bill of materialscomponent_list(1).xlsx
Software architecture diagramsystem_architecture.png
PCB schematic (image export)PCB Schematic.png (also under KiCAD Stuff/)
KiCAD project (native)KiCAD Stuff/ — Embedded Project.kicad_pro, .kicad_sch, .kicad_pcb, .kicad_prl
Teamteam.md
3D / mechanical design3d design/ (Fusion 360 .f3z)
Local dev (env + both servers)DEV-SERVERS.md

KiCAD: open KiCAD Stuff/Embedded Project.kicad_pro in KiCad. Local editor folders (.history/, *-backups/, lock files) are gitignored.


Running the PC applications

The host uses the same UART protocol as USB; the radio path is either Bluetooth Classic SPP (ZS-040 / HC-05) or BLE (HM-10 / Nordic UART). Full copy-paste flows (both apps, stop commands, ports) are in DEV-SERVERS.md.

  • Classic SPP (ZS-040 / HC-05): pair in macOS, then set MAZE_BT_SERIAL to the paired /dev/cu.* device (and MAZE_BT_BAUD, usually 9600). Applies to both the maze dashboard and the log viewer.
  • BLE: leave MAZE_BT_SERIAL unset. Point the dashboard at the robot with MAZE_BLE_ADDR (fixed address, skips scanning) or MAZE_BLE_NAME (scan by advertised name). The log viewer does not use MAZE_BLE_ADDR; it still expects MAZE_BT_SERIAL for Classic SPP.

Maze dashboard (first-time venv)

bash
cd "Bluetooth stuff/maze_dashboard"
python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
uvicorn app:app --reload --host 127.0.0.1 --port 8765

ZS-040 / HC-05 on macOS (Bluetooth Classic SPP) — pair the module in System Settings → Bluetooth, then pick the outgoing serial device (names vary; often under /dev/cu.*):

bash
ls /dev/cu.*
export MAZE_BT_SERIAL=/dev/cu.YourModule-DevB
export MAZE_BT_BAUD=9600
cd "Bluetooth stuff/maze_dashboard"
source .venv/bin/activate
uvicorn app:app --reload --host 127.0.0.1 --port 8765

After a successful connection, you can use export MAZE_BT_SERIAL=last to reuse bt_serial_last.json beside app.py.

Maze dashboard (BLE by address — example)

Use when the robot is on the BLE path and you already know its address:

bash
unset MAZE_BT_SERIAL
unset MAZE_BT_BAUD
export MAZE_BLE_ADDR=78:04:73:16:19:C7
cd "Bluetooth stuff/maze_dashboard"
source .venv/bin/activate
uvicorn app:app --reload --host 127.0.0.1 --port 8765

For scan-based BLE instead of a fixed address, omit MAZE_BLE_ADDR and optionally set MAZE_BLE_NAME. See Bluetooth stuff/maze_dashboard/app.py (module docstring) and ble_discover.py for UUID discovery.

Path preview (SVG map): The dashboard builds a turtle-geometry polyline from path strings and from training/solve turn lines in the log (FORCED_TURN, SOLVE_FORCED_TURN, SOLVE_NODE, etc.). The preview appends one grid segment after the last logged turn so the final leg and forced corridor exits show the same corners you see on the track; that step is visualization-only and does not change what the robot records or executes. Optional local-only regression tests for the map (not published on GitHub) may exist under Bluetooth stuff/maze_dashboard/; if you have them, run with python -m unittest in that folder using the project venv.

Log viewer (see Bluetooth stuff/log-viewer/package.json for scripts). This path uses ble_log_receiver.py and Classic SPP only — set MAZE_BT_SERIAL in the same shell.

bash
cd "Bluetooth stuff/log-viewer"
bun install
export MAZE_BT_SERIAL=/dev/cu.YourModule-DevB
bun run serve

Course project repository: ecng4504-maze-solver_team_5 — maze learning and solving per the ECNG 4504 charter.

Parts

99
QtyValueFootprintReferences
1610uCapacitor_SMD:C_0805_2012MetricC4, C16, C17, C19, C29, C30, C31, C39, C41, C43, C45, C47, C49, C51, C53, C55
14100nCapacitor_SMD:C_0805_2012MetricC2, C13, C14, C15, C18, C38, C40, C42, C44, C46, C48, C50, C52, C54
91N5819Diode_SMD:D_SMAD1, D21, D22, D23, D24, D25, D26, D27, D28
71kResistor_SMD:R_0805_2012MetricR28, R29, R30, R31, R32, R33, R35
610kResistor_SMD:R_0805_2012MetricR18, R23, R24, R25, R26, R27
6LEDLED_SMD:LED_0805_2012MetricD15, D16, D17, D18, D19, D20
5220Resistor_SMD:R_0805_2012MetricR17, R19, R20, R21, R22
5TCRT5000TCRT5000:OPTO_TCRT5000U3, U4, U5, U6, U7
212pCapacitor_SMD:C_0805_2012MetricC27, C28
215pCapacitor_SMD:C_0805_2012MetricC20, C21
21n8Inductor_SMD:L_0805_2012MetricL2, L3
21pCapacitor_SMD:C_0805_2012MetricC22, C25
21p2Capacitor_SMD:C_0805_2012MetricC23, C26
222pCapacitor_SMD:C_0805_2012MetricC11, C12
256kResistor_SMD:R_0805_2012MetricR34, R37
11n2Inductor_SMD:L_0805_2012MetricL1
11p6Capacitor_SMD:C_0402_1005MetricC24
12.2kResistor_SMD:R_0805_2012MetricR36
12nHInductor_SMD:L_0402_1005MetricL4
132.678kCrystal:Crystal_SMD_3225-4Pin_3.2x2.5mmY4
132MCrystal:Crystal_SMD_3225-4Pin_3.2x2.5mmY2
1AMS1117-3.3Package_TO_SOT_SMD:SOT-223-3_TabPin2U13
1AMS1117-5.0Package_TO_SOT_SMD:SOT-223-3_TabPin2U12
1ATmega2560-16AUAtmega:QFP50P1600X1600X120-100NU11
1Antenna_ShieldRF_Antenna:Texas_SWRA117D_2.4GHz_RightAE2
1CC2540F256RHARCC2540:QFN50P600X600X100-41NU1
1Conn_02x03_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ6
1L298NL298N:TO127P2020X500X2100-15U8
1SN74HC14DRSN74HC14DR:SOIC127P600X175-14NU16
1SW_PushButton_Switch_SMD:SW_SPST_PTS645Sx43SMTR92SW2
1Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ7
1Screw_Terminal_01x04TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-4-5.08_1x04_P5.08mm_HorizontalJ1

Similar boards

  • 2 layers216.3 × 115.1 mmElectric AI Wheelchair, the printed circuit board in 3D

    Electric AI Wheelchair

    prisca7c/Customized-AI-Electric-Wheelchair

    Manual wheelchair turned electric! This wheelchair uses electronic components such as modules and a PCB to make this wheelchair much for user interactive (and helps make life easier when you can't walk).

    129 parts
  • 4 layers99.2 × 98.9 mmMicromouse kicad, the printed circuit board in 3D

    Micromouse kicad

    tadzio8425/Micromouse

    Micromouse developed by the IEEE Robotics and Automation Society chapter of the Universidad de Los Andes, Bogotá (2023-2024).

    102 partsMIT
  • 2 layers120 × 103.9 mmMisaka, the printed circuit board in 3D

    Misaka

    TingliangZhang/Misaka-PCB-v3

    77 parts
  • 2 layers99.9 × 99.9 mmMaquina compostaje, the printed circuit board in 3D

    Maquina compostaje

    dani0421/Compostaje

    El SDA se conecta al pin 33 del ESP32 y el SCL al pin 36 de ESP32, cabe resaltar que en la placa no quedaran orificios para la pantalla, unicamente los pines para hacer la conexión.

    103 parts
  • 2 layers70 × 85 mmXkong13 battlebot, the printed circuit board in 3D

    Xkong13 battlebot

    yuxinz310/antweight-battlebot

    ESP32-based Wi-Fi-controlled antweight combat robot featuring two-motor differential drive, custom PCB design, a servo-actuated weapon, and integrated safety mechanisms.

    30 parts
  • 2 layers63.8 × 47.8 mmRover robot, the printed circuit board in 3D

    Rover robot

    deuteros76/rover-robot-PCB

    A multipurpose rover PCB for arduino projects using ESP32

    20 parts
  • 4 layers92.5 × 101.6 mmVCU, the printed circuit board in 3D

    VCU

    formulaslug/fs-4-schematics

    Electrical Design Repository for fs-4 schematics and PCBs

    225 parts7

Questions

How big is the Final Version PCB?

It measures 142.3 × 80.5 mm and has 4 copper layers, 1.6 mm thick.

What parts does the Final Version use?

99 parts, built around the ATMEGA2560-16AU, CC2540F256RHAR, L298N and TCRT5000. 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 Final Version KiCad files?

From the elshazlio/ecng4504-maze-solver_team_5 repository on GitHub, at the commit this page was made from: the board is Team 5 Embedded Phase 2 Submission/Final_Version/Final_Version.kicad_pcb and its schematic KiCAD Stuff/Embedded Project.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Final Version design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).