Introduction: Marble Maze Using Arduino (Inspired by SmartTronix)
This instructable is a step-by-step process into creating SmartTronix's "Build DIY Maze Game Using Arduino" instructable. I decided to follow his instructable while creating my own version for Ms. Berbawy's 2022-23 Principles of Engineering class as my SIDE (Students Involved in Discovering Engineering) project.
This is a marble maze game with a with a platform that tilts on two axes that runs using Arduino. The structure will primarily be made out of 3d-printed and laser-cut parts, and servos will tilt the marble maze platform.
Supplies
Electronics:
- Arduino
- Servo Motors
- Joystick Module
- Power Supply (I used a 9V battery holder)
- Jumper Wires
- Headers
- PCB or Breadboard (gerber file can be downloaded later I used JLCPCB for my PCB quote)
- USB-A to Micro USB cable
Other Materials:
- 3D Printing Filament
- Wood (for laser cutting)
- Glue (Any works but preferably strong, I used gorilla glue)
- Marble (Need less than 12 mm diameter, here's an 11 mm one)
Machines needed:
- 3D Printer
- Laser Cutter
- Soldering Kit
All the materials I used are linked. However, there is no need to use only the materials included in the link as all of them are easily replaceable.
Step 1: 3D Printing
The first step to this project is to 3d print the structural parts. These parts include the base, the maze platform, and the hinge. You can then print the smaller parts which include the arms that connect to the maze platform and the servos.
In SmartTronix's original instructable, his STL files are not included in the google drive folder he linked. Because of this, I redesigned the 3d-printed parts myself. My parts can be found here. You will need to print one of each of the maze platform, base, and hinge. You will need to print two of each of the arm STL files and the "Insert 1" STL file. You need to print four copies of the "Insert 2" STL file.
I printed these pieces using PLA filament with print and filament settings shown in the pictures above.
Step 2: Assemble the 3D-Printed Parts
Once you finish 3d-printing the parts, you must assemble them. This is fairly self-explanatory, as the main hinge connects the maze platform and the base and a pair of arms attaches to the platform. Attach the other pair to the servos and slide the servos into their designated spots. Use the "Insert 1" STL file to connect the hinge to the maze platform and the base. Attach the arms together and to the maze platform using the "Insert 2" STL File. A good substitute for this is to use 3 toothpicks if you would like to save some filament or if you need to adjust the resistance.
Step 3: Ordering the Custom PCB
If you would like to use the custom PCB SmartTronix provided for this project, you can order it at any site that allows instant quotes by simply uploading the gerber file (made by SmartTronix, file found here).
I used the site JLC PCB while SmartTronix used NextPCB. However, you can use any trusted PCB manufacturer. If you are not a PCB expert (I am not either), you can simply leave the settings at default and order the PCB.
Step 4: Assemble the Circuit
Using either a breadboard or a custom PCB you can begin to assemble the circuit. The custom PCB is made specifically for an Arduino Nano. Attach the arduino, servo motors, and the joystick module to the PCB by soldering (If you need a soldering guide, here is a simple one). Also, connect a power supply to the PCB. I used a 9V battery for this purpose.
SmartTronix provided a very useful diagram of the circuit in his instructable of this project. It is displayed above. I also provided one that uses the arduino uno.
Connect the wires of the servos and joystick as shown in the sketch:
- Arduino Pin 3 to orange wire in servo 1 (X-axis)
- Arduino Pin 4 to orange wire in servo 2 (Y-axis)
- Red & Brown wires to Arduino 5V and GND
- Arduino Pin A0 to Joystick pin VRx
- Arduino Pin A1 to Joystick pin VRy
- Joystick VCC and GND to Arduino 5V and GND
Once finished, your circuit should look somewhat like mine (You could use different pin headers, joystick modules, or you could use a breadboard instead of a PCB.
Step 5: Arduino Code
SmartTronix provided a prewritten Arduino sketch that you can use for this project. Plug the Arduino into your PC or laptop using any cable that has a Micro-USB attachment on one end.
Download the Arduino IDE and open it. Then, upload the sketch from the file below. Make sure to select the Arduino in the dropdown menu to be sure it recognizes the correct Arduino. If you need to troubleshoot and you are unsure if your Arduino is receiving inputs from the joystick, use the serial plotter and monitor. Instructions on how to use these can be found online.
Attachments
Step 6: Fine-tuning Arduino Code
This arduino code uses the servo library, as the primary purpose of the arduino is to control the servos.
To fine-tune the arduino code for your own purposes, simply edit the values that are used in the write function and the map function. If you want to change the direction that the servo spins, simply edit the value in the write function to 180 minus whatever value it currently has like I did. Also, if you would like your servo to spin more or less, edit the last value in the map function. This will allow you to fine-tune your servos to spin exactly as much as you want.
With some testing, you can find the right value for you. I required a pretty high value at first because my servos did not turn the maze platform enough due to high resistance between the motor and the arm.
Step 7: Design the Maze
For this step, you can either 3D print or laser cut your maze. I chose to laser cut the maze, but 3D printing can work equally well. You can find my laser cut files here. You can also make your own individual mazes that can easily be swapped out of the frame by following the dimensions given on my file. To easily generate mazes, you can also use a maze generator if you do not want to create one yourself.
I used 4 mm wood and created the dimensions for my laser cut files for that purpose. If you use a different thickness of wood, the dimensions would need to be different, as these pieces were made to fit perfectly together as 4mm pieces. The light red lines are the lines that will be cut. The black and white image of the maze is there for reference. There are a few extra maze walls on the bottom in case you need them. Its always good to have a few extra.
Step 8: Laser-Cut and Assemble Maze
You may skip this step if you are 3d-printing your maze.
Once you laser-cut the maze, use a strong glue such as gorrilla glue, wood glue, or super glue to glue the pieces together. You may need a precise nozzle as some pieces are very slim. If you used my laser-cut file, your maze should look something like the one above.
Step 9: Finish Assembling the Maze
Now that you have the maze itself, the 3d-printed structure, and the circuit, you can finish the overall assembly by sliding the servos into their spaces and attaching the maze to the 3d-printed maze platform (best to use glue to do this but if you do not want a permanent attachment, you can use velcro because tape would not hold the two pieces together well enough). Once you do that, you are finished and ready to start playing with your project!
YouTube Video Link: https://youtu.be/YJjivS5y69M