Introduction: Arduino Lego Maze

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida ( The project is a fully functional maze game made of Legos and powered by an Arduino Uno board. This project is based on the official Lego set number 21305. Although this version is heavily modified, and in fact built from scratch, You may use this set as a starting point. Instructions for building this set are available here:

Step 1: Design

The design implements S.N.O.T. (studs not on top) techniques for lettering as well as the tilting maze trays. This provides extra detailing and a sleek finish to the project.

Step 2: Joystick and Ball Enclosure

There is a built-in joystick on the side of the maze that is tilted at an angle for convenience of table top operation. Also embedded into the Maze is an enclosure which houses the balls used in the maze for easy transport.

Step 3: Electrical Component Access

On the size of the maze, one of the panels in removable to allow easy access to two ports on the Arduino Uno. This allows a wall power outlet to be used to power the maze. Also, the USB cable can be easily used to alter and update the code used to control the Maze.

Step 4: Maze Inserts

The Maze is designed to have modular inserts to allow for an infinite amount of replayability. In this particular model, there is a simple maze and a more intricate medieval maze. These can be customized into any style, theme, or difficulty level for all ages.

Step 5: Mechanical Control Mechanism

The control mechanism is based o the official Lego Ideas maze set #21305. However, it is a modified personal design that was made from scratch. It uses the same lever-arm and linkage system to control the trays, however servos are used to turn the Lego Technic parts. Each axis has it's own identical assembly to rotate the maze about the x and y axis independently.

Step 6: 3D Printing

In order to assure the correct gear ratios, gears were printed to be compatible with the Lego system. Specifically, Autodesk Inventor files of part number 32270 and 10978 were used to interface with the 3D printers.

Step 7: Electrical Control Mechanism

This diagram shows the breadboard setup for the electrical components of the maze. The servos and analog joystick are each attached to 5V and ground on the Arudino. Servo 1 is attached to digital input 1 on the Arduino and servo 2 is attached to digital input 2. The horizontal and vertical axis of the analog joystick are attached to analog input 1 and 2 on the Arduino.

Step 8: Coding

This code shows the sketch used to control the maze. It details how the reading from the analog joystick is used to manipulate the position of each servo motor. The interface used to made this control possible is an Arduino Uno micro-controller. This servo motor then interacts with the mechanical Lego components to allow the player to play with the maze.