Major project / autonomous systems

Autonomous maze
solving bot.

A compact mobile robot that senses walls, builds a map, and navigates a grid maze with no remote control.

Flood-fillBFSESP32C++IR sensing

01

Grid world

structured maze

02

Flood-fill

adaptive planner

03

ESP32

real-time control

04

2-wheel

differential drive

03 / algorithm

Explore first. Then run the shortest path.

The firmware is a two-state navigation engine: EXPLORING discovers the maze, then GOING_TO_GOAL follows a fresh distance map to the target. A final FINISHED state stops the motors.

01

Detect

front / left / right

02

Recompute

BFS from target

03

Move

lowest valid cost

firmware logic / C++

updateDistances(targetX, targetY);

int bestDir = -1;
int minVal = 255;

// Prefer continuing straight
if (!walls[x][y][currentOrient]) {
  int nx = x + dx[currentOrient];
  int ny = y + dy[currentOrient];

  if (distMap[nx][ny] < distMap[x][y]) {
    bestDir = currentOrient;
    minVal = distMap[nx][ny];
  }
}

// Otherwise choose the best neighbor
for (int d = 0; d < 4; d++) {
  if (!walls[x][y][d]) {
    int nx = x + dx[d];
    int ny = y + dy[d];

    if (distMap[nx][ny] < minVal) {
      minVal = distMap[nx][ny];
      bestDir = d;
    }
  }
}

State machine

EXPLORING mark cells, detect walls, seek the nearest unvisited cell.

GOING_TO_GOAL navigate toward goalX = 1, goalY = 1.

FINISHED stop both motors after arrival.

Movement policy

  • Wall map: addWall() writes both sides of every wall.
  • Turning: faceDirection() resolves 90° or 180° changes.
  • Cell travel: moveOneCell() uses IR correction and encoder pulses.

05 / hardware

Built for feedback, not spectacle.

The platform pairs an ESP32 with IR wall sensors, encoder-equipped N20 motors, a motor driver, and a caster wheel. The electronics keep the signal path short and the mechanical footprint compact.

  • ESP32 microcontroller
  • IR sensor module × 3
  • N20 encoder motors × 2
  • Motor driver + battery supply
  • Differential wheels + caster

03 / testing & calibration

Calibration is part of the algorithm.

Sensor thresholds are tuned against wall distance, while motor timing and encoder feedback are checked for straight motion and repeatable 90-degree turns. Tests progress from isolated actions to full-maze runs.

Validation sequence

01Sensor read + threshold
02Straight-line correction
03Turn-in-place repeatability
04Unknown-wall discovery
05Goal reach + path replay