Introduction: Awesome Lego Maze
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).
I will show you how to upgrade and automate the Lego Maze Game by controlling it with an old-school Nintendo controller.
The game uses an Arduino Uno and a pair of Lego NXT Motors to translate the input from the NES controller into motions of the game table. The point of the game is to move a marble from the castle to the village by tilting the table.
The system has two modes: one is a normal game mode where the laze moves with the directional arrow on the NES controller; the other is "Earthquake Mode" that causes the table to shake when the A or B button is pressed. The A button will shake the front motor, the B button will shake the right motor. This useful for getting the ball out of traps.
This design uses DC motors instead of the servos. The code moves the motor in small increments whenever a directional arrow is pressed. Some trial and error was required to get the increment size small enough to achieve high resolution and still move the motor. The motors have a built in gear train that provide enough friction to keep the motor and the maze stationary between moves.
An H bridge was necessary to power the NXT Motors. The pins on the Arduino did not have enough current on their own. This also made the code much simpler.
Step 1: Gather Parts
- Arduino IDE
- (Optional) Visual Studio 2015 Community Edition or higherwith the Arduino extension from vMicro
- 1 x Arduino Uno microcontroller
- 2 x LEGO MINDSTORMS Interactive Motor (9842)
- 2 x Breadboard Connector Kit for NXT or EV3
- 2 x Lego Mindstorm Cables
- 1 x USB Panel Connector Female: StarTech 1-Feet Panel Mount USB Cable B to B - F/M (USBPNLBFBM1)
- 1 x Motor Control H Bridge: Adafruit TB6612 1.2A DC/Stepper Motor Driver Breakout Board
- 1 x NES Controller Plug: Long Nintendo NES Repair Part Genuine OEM Original
- 1 x NES Classic Controller
- 1 x USB Power Outlet, 5V DC, 1 Amp
3D Printed Parts:
- 2 x Indicator Arrows
- 1 x Front Motor Mount
- 1 x Right Motor Mount
- 1 x M2.5 brass male to female standoff 6 mm with 6 mm
- 1 x POW3U PowerBoard-3U with Power Rails, 1 Sided PCB, 3.94 x 6.30 in (100 x 160 mm)
- 1 x Base Plate: 12 inch x 12 inch x 3/4 inch white pine
- 2 x Side Walls: 12 inch x 5 inch x 3/4 inch white pine
- 2 x Front/Back Panel: 13-1/4 inch x 5 inch x 1/8 inch oak plywood
- 1 x Game Table Floor: 12 inch x 12 inch x 1/8 inch oak plywood
- 4 x Game Table Footers: 1/2 inch x 1/2 inch x 6 inch pine molding strips
- 2 x Game Table Floor Supports: 1/2 inch x 1/2 inch x 6 inch pine molding strips
- 16 x Front/Back Panel Fastener: Round Slotted #4 1/2 inch brass wood screws
- 6 x Side Wall Fastener: Flat head #6 1-1/2 inch brass wood screws
- 4 x Side Wall Fastener: Flat head #6 1 inch brass wood screws
Step 2: Assemble Circuit
- Mount the Arduino to the perf board (I used Velcro command strips for easy removal)
- Solder the H Bridge and NXT motor connectors to the perf board.
- Using jumper wires connect the Arduino to the H bridge. Note: jumpers are pushed into the arduno sockets but are soldered to the perf board on the H bridge side.
- Wire the jumpers for the NES Connector to the Arduino by pushing the jumper pins into sockets, but do not connect jumpers to NES Connector just yet.
- The perf board has power rails to distribute +5 volts and ground. Use jumpers to connect the Arduino 5V and GND pins to the appropriate rails and the rails to the NES connector and H bridge power pins.
Step 3: 3D Print Motor Mounts
The motor mounts and the indication arrows were 3D printed with the following files.
The 3D printers was a (printer specs), with PLA material.
These were designed using SOLIDWorks also included below (*.SLDPRT)
Step 4: Prepare the Front and Back Panels
The front panel needs a hole for the Nintendo connector, 0.65 inch x 0.97 inch. I put mine 2 inches in from the right and 1 inch from the bottom.
The back panel needs a hole for the USB connector, 0.48 inch x 0.44 inch. I put mine 2 inches in from the right and 2 inches from the bottom.
I used a laser cutter to cut both the holes and the overall panels from 1/8 inch oak plywood and to inscribe the Letters on the front.
Both panels were 5 inch x 13-1/4 inch
Step 5: Assemble the Box
- Use the flat head wood screws to attach the side walls to the base plate.
- Use the 1 inch flat head wood screws to attach the game table floor supports to the side walls.
The supports should be at least an inch from the top to the side wall.
- Use the brass standoffs to mount the assembled circuit card to the base plate. I choose to drill a shallow hole into the base plate and glued the standoffs in place.
- Use the round head wood screws to attach the front and back panel.
- Thread the NES connector cable through the front panel hole and glue the connector jack in place.
Connect other end of the cable to the jumper from the perf board by pushing the jumpers into the cable connector. (Refer to the circuit diagram for pin assignment)
- Attache the USB Panel Connector to the rear panel with the mounting screw supplied.
- Plug the NXT Motor Connectors into the perf board.
Step 6: Add the Game Table Floor
- Cut a small notch out of one corner of the game table floor.
- Drop the game table floor onto the side supports, leading the NXT Motor Connectors through the notch hole. Take note of which is motor A (front motor) and motor B (right motor).
I left the floor unsecured, relying on the friction fit between the floor and the side of the box to keep it in place and still let me have access to the electronics.
Step 7: Assemble the Game Table
Assemble the Game Table according to the instructions supplied with the Lego Maze kit, with the following:
- No need to attach the control nobs since the motors will be moving the maze.
- For the front motor mount I left off the bottom most right pin.
- For the right motor mount I left off the bottom most left pin.
- The spacers attached to the sides of the LEGO base are not need as well
Glue the Game Table Footers to the under side of the LEGO Maze Game Table.
Step 8: Attach the LEGO Pins to the 3D Printed Motor Mounts
Attach the Lego pins to the Motor mounts.
Attach the black pins to the top most holes.
The longer blue pins go in the bottom most hole of each motor mount.
Step 9: Add the Motor Mounts
Attach the Motor mounts to the side of the lego maze.
The mounts should straddle the lego posts.
The motor mount posts should point at each other.
Then slide arrows over the posts.
Step 10: Attach the NXT Motors
Now attach the motors to the Lego posts, lining up the gear and the bottom holes to the motor supports.
Step 11: Install the Game Table
Drop the game table onto the box and connect the NXT Motor wire to the respective motors.
Again Motor A in the front, Motor B on the right.
Step 12: Upload the Code to the Arduino
- Plug in the back panel USB to your computer.
- Unzip the folder and open the NES.ino file in the Ardunio IDE and upload.
This code has three files
NES.ino - Main Ardunio file responsible for the SetUp and main Loop.
Decode_Nes.ino - responsible for taking the input from the NES controller and moving the motor appropriately.
Motor.ino - defines the methods for moving the Lego NXT motors.
Read_Nes.ino - defines methods for reading the NES controller data and setting the byte data variable
Step 13: Play and Enjoy!!!
Plug the in a Nintendo controller to the front.
Plug in the USB power to an outlet