Robot in a Puzzle Maze

by Danique Veldscholte in Circuits > Arduino

1995 Views, 22 Favorites, 0 Comments

Robot in a Puzzle Maze

WhatsApp Image 2023-01-23 at 05.06.54 (1).jpeg

For this project I made a moving robot that can sense and react to coloured blocks placed in it's path. It will start driving forward until the ultrasonic sensor detects it is close to an object. It will then stop and read the colour and react by either turning left or right. Then it will start moving forward again and repeat the process.


With the black blocks you can build different setups to create a maze game. You turn on the robot and while it moves around the maze, you place the coloured blocks to lead it to the exit.

Supplies

Arduino Components

Arduino Uno

Jumper Cables (Male to Male)

Jumper Cables (Male to Female)

RGB Sensor TCS34725

Ultrasonic Sensor HC-SR04

DC Motor Driver L298N

2x TT Motors and Wheels

Battery Holder with DC Jack Connection

4x AA Batteries

USB-B 90 degree angle adapter


Other Arduino Build Supplies

Breadboard

USB-B to USB-A Cable

Small Tyraps

Electrical Tape

Double Sided Tape


Case Supplies

Perspex

Threaded End M4

Bush Spacers M4

Flat Washers M4

Helical Spring Washers M4

Nuts M4

Felt Pad


Chassis Supplies

Aluminium moulding

Screws M3

Bush Spacers MC

Nuts M3


Maze Blocks Supplies

Wood

Screws

Paint (2 colours)


Tools

Waterproof Marker

Ruler

Cutting Pliers

Stripping Pliers

Small Phillips Screwdriver

Wrench

Soldering Iron and Soldering Tin

Heat Gun

metal file

Drill

Saw

Concept

WhatsApp Image 2023-01-23 at 07.05.38.jpeg
Prototype-01.jpg

While brainstorming four ideas popped into my head. The first one was a project that my dog could interact with to make the Arduino react and do something, but that didn't seem to original. The second was to make a animatronic figure that I could animate with code, but that seemed a little to ambitious for a first project. The third idea was to make some sort of game with a flashlight input, but that idea wasn't very concrete yet. The idea to make a robot maze game was the idea I decided to go with. I liked that it was a game that you can make new levels for to keep it fun for a longer time. And it was something I could immediately visualize and was looking forward to building.


I started sketching the idea I had in my head. Not having worked with or having knowledge of Arduino before this project, I didn't yet know what components I would need to make it do what I had wanted. So the sketch was roughly what I had in my mind that it might look like. After the pencil sketch I made a cleaner version in Illustrator to be able to better present my concept.


The next step was to think about how I could build the robot. The first obstacle was the size of the robot. My original idea was to make a tabletop game with a board about 40x40cm. But for that to work my robot had to be tiny. After discussing it with my teacher I realized that wasn't gonna work. I was gonna have to build the robot first and depending on it's size create a game area for it to ride around in.


The first thing the robot had to do was be able to move forwards and also turn. I considered all my options from using caterpillar tracks to having the robot follow magnets connected to the board. I thought this way I could keep it relatively small compared to using four wheels, until I realized I could also use just two wheels to make it move as well as turn by simply having one wheel turn forward and the other backwards.


Other than the wheels I needed an RGB sensor, distance sensor and a battery holder so my robot could move without being connected to a wire.

Breadboard Testing

WhatsApp Image 2023-01-23 at 05.11.42.jpeg
WhatsApp Image 2023-01-23 at 05.12.25 (2).jpeg

I started by watching some general tutorials that would go over the basics of how to use and Arduino and what all the components on the board where used for. When I had gained a basic understanding I started testing. I tested one component at a time adding them all to my breadboard to see If I could get them to work separately. I searched for some schematics of the pieces I had and would try to figure out what each jumper cable was connected to and why. This became easier after each component I added. All of the would need power, they needed to be grounded and the other jumper cables were either inputs or outputs to send or receive data to and from the components.

After connecting everything on the breadboard I would look up what code was needed to test the component. I went over every line of code to make sure I understood what I did, otherwise I wouldn't be able to write my one code later on. For the ultrasonic sensor as well as the RGB sensor I tested if they worked with a Println.

When It was time to test my TT motors I realised I needed a motor driver to get them to work, which I quickly ordered to be able to test them as well. I couldn't test the motors without soldering so I moved on the the next step.

Downloads

Soldering

WhatsApp Image 2023-01-23 at 05.11.43 (2).jpeg
WhatsApp Image 2023-01-23 at 05.11.44 (2).jpeg
WhatsApp Image 2023-01-23 at 05.11.45 (1).jpeg
WhatsApp Image 2023-01-23 at 05.11.46 (3).jpeg

I decided not to use a stripboard to once again keep everything as compact as can be. It wasn't to hard to transfer all the wires from the breadboard to the components itself. The only thing I ran into was how I was gonna power and ground every component with the limited pins on my Arduino Uno. After asking my father for advice he suggested to screw all of the power wires together in the power slot and all the ground wires together on the ground slot on the driver shield. After I stripped the wires and tried, I realised that they would fall out really easily. So that wasn't an option. I also tried putting the wires in without stripping them first, but that also wasn't sturdy as it was to small of a space for four wires. I ended up stripping the wires again and wrapping and soldering them all together. After I wrapped them with electrical tape so they wouldn't short circuit anything. After I tested that everything still worked, I started to puzzle my components together to see how they could fit on a construction. Before doing anything definitive I held everything together with tywraps. By manoeuvring the pieces around a lot, wires would constantly end up breaking resulting in my having to solder them back on again. I realized I could avoid a lot of soldering and make my design more durable if I had male to female wires instead of the male to male wires that I had used this far. So I decided to order some had to wait until they arrived to continue my project.

Optimized Reassembly

WhatsApp Image 2023-01-23 at 05.08.47.jpeg
WhatsApp Image 2023-01-23 at 05.11.43.jpeg
Schematic.jpg

After the new male to female wires came in I took my whole Arduino apart. I tried to clean the soldering tin of the components as best as I could. Which was kind of difficult for the ultrasonic sensor since the female wires wouldn't slide on the tin residue on the pins. By some fine sandpaper did the trick. My father helped me properly connect the motor driver to the Arduino. The rest was mostly just connecting wires. The only parts I needed to solder where the RGB sensor and the TT motors. Connecting the wires I also made sure to use a clear colour system. Yellow for power, black for ground, blue and green for inputs and outputs and lastly red, orange and purple to connect the driver motor to my Arduino board. I also used double sided tape to stick my battery holder on the backside of the Arduino. After once again testing that everything still worked, It was time to build the construction around it.

Case Design

WhatsApp Image 2023-01-23 at 05.11.42 (1).jpeg
WhatsApp Image 2023-01-23 at 05.09.11 (2).jpeg
WhatsApp Image 2023-01-23 at 05.09.10 (2).jpeg
WhatsApp Image 2023-01-23 at 05.09.10.jpeg

Designing and building the case was surprisingly the hardest part of the whole project. This also took the longest time out of any step. I first tried making a case from wood. The idea was to make a cube where most of the components would fit into. You could open it at the back to get to the electronics. I made some quick sketches of what that would look like and decided to add a separate smaller cube on top that would act like the robots head. This would hold the Ultrasonic and RGB sensors. But after making the main wooden body and letting the wood glue dry overnight, I wasn't very happy with the results. The box came out very wonky and even if that wasn't a problem I felt like this big empty wooden box took away all the interesting shapes of the robot. I started to like how to ultrasonic sensor with the RGB sensor underneath kind of resembled the shape of a head and how the battery pack had basically become the robots stomach. All the electronics and wiring gave the robot character that I felt was a shame to cover up. So instead I thought of a different design from Perspex that would act as a skeleton without completely covering up the robot. This also made it way easier to access any components after the robot was fully build. My plan was to make an angled piece behind and under the robot. And a smaller square piece that would act as it's face. I went to the construction store to buy all the supplies I needed and got to work. My father helped me a lot with the build of the skeleton and after three days the robot was standing on it's own.

Programming & Maze Design

WhatsApp Image 2023-01-23 at 05.06.55 (1).jpeg

I couldn't really start programming until the constructing of the robot was complete. Because for most of my code I needed the wheels to be attached. So I was happy to finally see my robot in action. I made it drive forward unless It was a small distance from an obstacle, in which case It would stop and turn to the left. I tested this by walking around with my laptop in hand that had the USB-B cable connected to the robot on the floor. Which felt like I was taking my robot for a walk. I did it this way because by plugging in the batteries the motors didn't seem to work. All the led's on the boards and components would be lit, indicating that they were powered, but the robot would not drive. Sometimes I would drive for a couple seconds after just disconnecting the USB-B cable with the batteries already connected, but it was very unreliable.

At this point I had an obstacle avoiding robot that would turn left until it's path was clear and it could go forward again. The only programming left was to make it turn different directions based on the colour it detected. So I first needed to create the maze pieces. I cut a couple wooden planks into smaller pieces and screwed them together so they had a 90 degree corner. After that I painted two of the blocks red and one black. My maze pieces were ready to use.

I went back to programming and started by observing the data the RGB sensor would recieve from the red and the black blocks respectively. I made a new if/else statement for the robot to turn left or right and tested it once again. The robot would now turn left when it detected a black block and right when it detected a red block.

Downloads

Final Product & Conclusion

WhatsApp Image 2023-01-23 at 05.06.53 (2).jpeg
WhatsApp Image 2023-01-23 at 05.06.52.jpeg
WhatsApp Image 2023-01-23 at 05.06.53 (1).jpeg
WhatsApp Image 2023-01-23 at 05.06.53.jpeg
Robot Maze Game with Arduino

The robot is finally finished! I am very happy to have been able to make my robot do what I wanted it to do, even though it ended up looking very different then I had envisioned at the very start of this project. I leaned a lot about Arduino and electronics in general. For example at some point throughout the project I realized that a game controller is also nothing more then a board with components, code and a case. For future projects I will have a way better understanding of what is possible with an Arduino.

There are some things I would have done differently with the knowledge I have now. The biggest thing is the battery problem. My driver motor needs a separate 12 volt power supply, but by using batteries that connect to the DC jack the voltage is converted into 5 volt. Therefore my robot can not drive at the moment without the USB B cable being connected. This causes the robot to not turn a perfect 90 degrees because it's being held back slightly by the cable. I also would have 3D printed a case to make it fit perfectly. Right now my robot is a little crooked because the Perspex wasn't bended perfectly. And lastly I would have made more and better looking maze pieces. I ran out of wood and time to make more before the deadline.

Even though there were lots of things I would do different, I really enjoyed being able to build my robot. It's one thing to write code and see it working on a screen, but another to have it be able to move physical objects right in front of you.