Robot Solves Line Mazes with a Plethora of Photoreflective Sensors

The Chicago Area Robotics Group (ChiBots) holds a robotics competition semiannually. If enough participants express interest, the event includes a Line-Maze Solving contest. The maze consists of straight white lines on a dark surface, instead of a maze with physical walls, in order to save on arena cost and weight.

A number of years ago, I built this robot, which successfully navigated the maze. The robot is named “All Right”, because it solves the maze using right turns.

Maze-solver multideck robot.

Maze-solver multideck robot.

This article provides photographs and descriptions of the robot’s various parts, including floor detection sensors and motor encoders discs. There is a movie on the last page of this article that demonstrates the robot actually navigating through a line maze.

Let’s begin with a movie tour of the robot itself:

Overview with Controls and Display

The robot is approximately 18 cm wide x 15 cm deep x 12 cm tall. It weighs 725 grams.

Overhead photo of maze-solving robot with LCD and pushbuttons.

Overhead photo of maze-solving robot with LCD and pushbuttons.

The top of the robot is a 1/8-inch thick smoky gray acrylic sheet. It is attached with red anodized aluminum socket-cap screw fasteners.

A large red rectangular power switch connects to the LiPoly (lithium polyester) battery pack. Two LiPoly cells provide nearly 8.4 volts when fully charged, going down to around 7 volts when exhausted. There are screw holes on the base for a standard 6-cell AA alkaline battery holder, but the LiPoly batteries weigh much less (which improves speed).

When powered on, the main circuit board flashes a purple LED to indicate the microcontroller (MCU) is operating. If a software bug causes the microcontroller to hang, the purple LED stops blinking.

There is also a yellow LED that turns on whenever the robot senses it is atop a line intersection. This makes it easier to see from afar if the robot’s high-level processing is working correctly. The yellow LED also adds to the visual entertainment value.

Four pushbuttons control the operation of the robot and the LCD.


Many pages of useful information are displayed on the robot’s LCD.

LCD maze, direction, and x-y coordinates.

LCD maze, direction, and x-y coordinates.

As the robot is driving the course, it can display the maze segments as it discovers them. The screen starts with all black squares representing unknown territory, just as “fog-of-war” is commonly simulated in adventure games.

The ChiBots line-maze course consists of 6-inch x 6 inch tiles with orthogonal lines. Each square on the screen represents a 2-inch segment.

(In practice, the arena tiles can be real or virtual. That is, the maze could be laid out on a large piece of paper using six-inch segments of tape. It doesn’t matter either way.)

The robot tracks its horizontal and vertical tile position and displays it as 'H' and 'V' on the LCD.

The robot also displays 'N', 'S', 'E', and 'W' for its current direction, after being told its initial compass heading.

LCD wheel encoder sensor values.

LCD wheel encoder sensor values.

This robot includes two wheel encoder discs with light and dark segments. The robot watches for brightness changes as the wheel rotates. The robot measures how far it has moved by keeping count of the number of dark-to-light and light-to-dark transitions on the disc.

The LCD page shown above, displays sensor values and current encoder counts to aid in debugging. The wheel can be rotated by hand to watch the sensor values change and the counts go up or down.

If the robot didn’t have an encoder to count wheel rotations, it wouldn’t be able to accurately display the horizontal and vertical tile position. It could apply power to the wheels for a specific amount of time, but the actual distance moved would vary based on the battery voltage. The robot can’t rely on intersections to count tiles, since the maze could contain a straightaway that is multiple tiles in length.

Of course, a maze-solving robot doesn’t absolutely require wheel encoders. Because the ChiBots maze is simply-connected (no loops), it can be solved by consistently turning right or consistently turning left when the robot reaches a fork in the path. Therefore, the robot doesn’t need to keep track of distance travelled nor does it need to remember or display the maze.

Minimum, current, and maximum front-floor sensor values on an LCD.

Minimum, current, and maximum front-floor sensor values on an LCD.

All Right features nine sensors for detecting the white lines and intersections on the floor. The sensors have emitters that bounce light off of the floor and into a photo-sensitive detector. The amount of light that is reflected allows the robot to determine whether it is sitting on a light line or the dark floor.

Each sensor’s historical minimum value, current value, and historical maximum value are displayed on one of the LCD pages. Pressing the Clear pushbutton resets the min and max to the current value.

After resetting the values, the robot can be placed on a neutrally reflective surface. All of the sensors should show minimum, current, and maximum values in the same approximate range as each other. If a sensor is bad or noisy (or simply needs adjustment), its minimum or maximum value will differ significantly from the other sensors.

LCD raw multiplexed sensors.

LCD raw multiplexed sensors.

In total, this robot has 24 analog inputs!

Note: The pushbuttons could be read as digital signals, but the microcontroller didn’t have any spare digital pins.

When I first wired up the robot, I hadn’t mapped out where each of the inputs were connected. The connections are complicated to determine because this robot includes three addressable 74LV4051 analog multiplexer chips to interface the microcontroller to all of the inputs.

Instead of figuring out all of the paths in my head, I wrote an LCD routine that displays the minimum, current, and maximum value for all of the inputs (with four inputs shown at the same time). By waving my hand in front of a sensor, or pushing a button, I could quickly determine which sensor connects to which input by empirical evidence.

Because this information proved to be so useful, and because I can still add six more sensors, I decided to leave these pages in the LCD display routines.

Heartbeat, Battery Indicator, and Other Screens

The 4x20 liquid-crystal display is controlled by the same algorithms designed into my first major robot, Bugdozer. In fact, there are many other LCD pages that can be displayed on this robot, besides the screenshots shown in this article. See Bugdozer LCD for additional examples.

Worth noting are the heartbeat and battery voltage icons in the lower-right corner of the display. The heartbeat icon serves the same purpose as the purple LED -- the heart throbs to show that the microcontroller is operating. And, although there is a battery voltage page that includes the exact voltage spelled out in volts, the battery icon in the corner of every page provides an instant check.

Now let’s take the cover off and look inside the robot...