

Final Version
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
7ATMEGA2560-16AU
TQFP-100(14x14)-40℃~+85℃ 10bit 16MHz 256KB 4.5V~5.5V 4KB 8 Bit 86 8KB AVR Built-in FLASH TQFP-100(14x14) Microcontrollers (MCU/MPU/SOC) ROHSMicrochip TechnologyMicrocontrollers (MCU/MPU/SOC)CC2540F256RHAR
WQFN-40-EP(6x6)-40℃~+85℃ -93dBm 19.6mA 1Mbps 2.402GHz~2.48GHz 2.44GHz 24.6mA 2V~3.6V 4dBm Bluetooth SPI、USB Supports RSSI function transceiver WQFN-40-EP(6x6) RF Transceiver ICs ROHSTexas InstrumentsRF Transceiver ICsL298N
Multiwatt-15-25℃~+130℃ 2 2A 4.5V~7V Bipolar Driver Overcurrent Protection、Over temperature protection Yes Multiwatt-15 Stepper Motor Driver ROHSHGSEMIStepper Motor DriverTCRT5000
DIP-4-25℃~+85℃ 0.4V 1.25V 100mA 15mm 70V 950nm Phototransistor DIP-4 Reflective Optical Interrupters ROHSVishay IntertechnologyReflective Optical InterruptersAMS1117-3.3
SOT-223-40℃~+125℃ 0.003%Vout 1 1.1V@(800mA) 15V 1A 3.3V 5mA 72dB@(120Hz) Fixed Over Current Protection、Short Circuit Protection、Thermal shutdown Positive SOT-223 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSAdvanced Monolithic SystemsVoltage Regulators - Linear, Low Drop Out (LDO) RegulatorsAMS1117-5.0
SOT-223-40℃~+125℃ 1 1.3V 15V 1A 5V 60dB Fixed Positive Short Circuit Protection、Thermal shutdown SOT-223 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSAdvanced Monolithic SystemsVoltage Regulators - Linear, Low Drop Out (LDO) RegulatorsSN74HC14DR(LX)
SOP-14Inverterslingxingic
README
README.mdECNG 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.
-
Hardware and sensing
We brought up five reflective sensors (left-to-right array), differential drive via motor drivers, and wireless UART onSerial1(HM-10 BLE or ZS-040 / HC-05 classic) so the laptop could see the same telemetry as USB debug. -
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. -
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. -
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, orBfor dead-end / U-turn). Dead ends are detected when the line is lost for long enough and recovered with a U-turn and a recordedB. -
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. -
Optimizing the remembered path
After training, the firmware folds the raw path: any middleB(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. -
Solve mode
In solving, the robot walks the optimized sequence: at each true decision node it executes the next character ofoptimalPath. 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. -
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 commandTRAIN/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
| Deliverable | Location |
|---|---|
| MCU firmware (final) | working_code.ino |
| Backend (FastAPI, BLE, WebSockets) | Bluetooth stuff/maze_dashboard/ |
| Web UI (log viewer) | Bluetooth stuff/log-viewer/ |
| BLE helper scripts | Bluetooth stuff/ble_log_receiver.py, Bluetooth stuff/ble_scan.py, Bluetooth stuff/requirements.txt |
| Bill of materials | component_list(1).xlsx |
| Software architecture diagram | system_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 |
| Team | team.md |
| 3D / mechanical design | 3d 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 setMAZE_BT_SERIALto the paired/dev/cu.*device (andMAZE_BT_BAUD, usually9600). Applies to both the maze dashboard and the log viewer. - BLE: leave
MAZE_BT_SERIALunset. Point the dashboard at the robot withMAZE_BLE_ADDR(fixed address, skips scanning) orMAZE_BLE_NAME(scan by advertised name). The log viewer does not useMAZE_BLE_ADDR; it still expectsMAZE_BT_SERIALfor Classic SPP.
Maze dashboard (first-time venv)
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 8765ZS-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.*):
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 8765After 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:
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 8765For 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.
cd "Bluetooth stuff/log-viewer"
bun install
export MAZE_BT_SERIAL=/dev/cu.YourModule-DevB
bun run serveCourse project repository: ecng4504-maze-solver_team_5 — maze learning and solving per the ECNG 4504 charter.
Parts
99| Qty | Value | Footprint | References |
|---|---|---|---|
| 16 | 10u | Capacitor_SMD:C_0805_2012Metric | C4, C16, C17, C19, C29, C30, C31, C39, C41, C43, C45, C47, C49, C51, C53, C55 |
| 14 | 100n | Capacitor_SMD:C_0805_2012Metric | C2, C13, C14, C15, C18, C38, C40, C42, C44, C46, C48, C50, C52, C54 |
| 9 | 1N5819 | Diode_SMD:D_SMA | D1, D21, D22, D23, D24, D25, D26, D27, D28 |
| 7 | 1k | Resistor_SMD:R_0805_2012Metric | R28, R29, R30, R31, R32, R33, R35 |
| 6 | 10k | Resistor_SMD:R_0805_2012Metric | R18, R23, R24, R25, R26, R27 |
| 6 | LED | LED_SMD:LED_0805_2012Metric | D15, D16, D17, D18, D19, D20 |
| 5 | 220 | Resistor_SMD:R_0805_2012Metric | R17, R19, R20, R21, R22 |
| 5 | TCRT5000 | TCRT5000:OPTO_TCRT5000 | U3, U4, U5, U6, U7 |
| 2 | 12p | Capacitor_SMD:C_0805_2012Metric | C27, C28 |
| 2 | 15p | Capacitor_SMD:C_0805_2012Metric | C20, C21 |
| 2 | 1n8 | Inductor_SMD:L_0805_2012Metric | L2, L3 |
| 2 | 1p | Capacitor_SMD:C_0805_2012Metric | C22, C25 |
| 2 | 1p2 | Capacitor_SMD:C_0805_2012Metric | C23, C26 |
| 2 | 22p | Capacitor_SMD:C_0805_2012Metric | C11, C12 |
| 2 | 56k | Resistor_SMD:R_0805_2012Metric | R34, R37 |
| 1 | 1n2 | Inductor_SMD:L_0805_2012Metric | L1 |
| 1 | 1p6 | Capacitor_SMD:C_0402_1005Metric | C24 |
| 1 | 2.2k | Resistor_SMD:R_0805_2012Metric | R36 |
| 1 | 2nH | Inductor_SMD:L_0402_1005Metric | L4 |
| 1 | 32.678k | Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm | Y4 |
| 1 | 32M | Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm | Y2 |
| 1 | AMS1117-3.3 | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U13 |
| 1 | AMS1117-5.0 | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U12 |
| 1 | ATmega2560-16AU | Atmega:QFP50P1600X1600X120-100N | U11 |
| 1 | Antenna_Shield | RF_Antenna:Texas_SWRA117D_2.4GHz_Right | AE2 |
| 1 | CC2540F256RHAR | CC2540:QFN50P600X600X100-41N | U1 |
| 1 | Conn_02x03_Odd_Even | Connector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_Vertical | J6 |
| 1 | L298N | L298N:TO127P2020X500X2100-15 | U8 |
| 1 | SN74HC14DR | SN74HC14DR:SOIC127P600X175-14N | U16 |
| 1 | SW_Push | Button_Switch_SMD:SW_SPST_PTS645Sx43SMTR92 | SW2 |
| 1 | Screw_Terminal_01x02 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_Horizontal | J7 |
| 1 | Screw_Terminal_01x04 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-4-5.08_1x04_P5.08mm_Horizontal | J1 |
Similar boards
- 2 layers120 × 100 mm

- 2 layers216.3 × 115.1 mm

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 mm

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 mm

- 2 layers99.9 × 99.9 mm

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 mm

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 mm

Rover robot
deuteros76/rover-robot-PCB
A multipurpose rover PCB for arduino projects using ESP32
20 parts - 4 layers92.5 × 101.6 mm

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).