Introduction: Autonomous Wall Follower

In this project we will be using an Arduino Uno to make a wall following robot, with the addition of an extra distance sensor, it could easily be turned into a maze solving robot with a few tweaks. The robot keeps at a certain distance from the right wall and when it comes across a corner it will turn and follow a new wall (including curved ones). Apart from we Arduino, we will also be using a type of H-Bridge controller which controls two DC motors at once. We will also we running the power through this device.

This project is good for all ages and can easily be built off as it gives foundation logic for other projects and improvements.

Supplies

The supplies needed to build this project are:

  • Arduino Uno
  • 2x 9V batteries
  • 2x DC motors
  • 2x Wheels
  • Multi-directional support wheel (I just made mine form Lego and will explain how if you wish to do this)
  • 3x Distance sensors (2 will work if you don't plan on making this into a maze robot)
  • 3x Mini bread boards
  • L298N controller
  • 2x Battery connection wires
  • 16x male to male jumper leads
  • 6x female to male jumper leads
  • Cardboard

Step 1: Starting Build

  • For the base of the robot, we are going to cut out a 12.5 x 9 cm piece of cardboard. Make sure it's strong enough to hold your components. Another option might be 3-D printing or using acrylic but for simplicity, cardboard works just fine.

Step 2: Place Motors

  • On the bottom hot glue, the DC motors parallel with each other and so the turning part faces the outside for the wheels to be put on.

Step 3: Attach Distance Sensors

  • Attach the 3 breadboards to the front of the cardboard on the other side for the distance sensors to connect to. The Arduino will sit above these with another small piece of cardboard or you can use acrylic as I use.

Step 4: Attach Motors to Controller

  • Get 4 jumper leads and cut off the ends and strip the wire. The prong sides go into the motors and then the left 5V and GND goes into the left side of the controller, the right goes into the right side. To put them in you will need to unscrew the screws and refasten. For a better indication on wiring refer to next step.

Step 5: Make Supporting Wheel (optional)

  • For this, we will need a supporting wheel and I just decided to make mine out of lego. It is able to bevel in all directions.
  • Using the parts attach as in the pictures and hot glue the top to the front bottom of the cardboard. Making sure the front is still able to turn.

Step 6: Attach Wires

  • Now attach the distance sensors through the L298N controller for power and connect the ECHO and TRIG pins to the analog on Arduino. Attach all 6 male to male jumper leads for pins 4-10. The circuit diagram I made will help with the wire connections as it does get very messy with the sheer amount.

Step 7: Upload the Code

  • The robot tries to stay at a target distance by changing the motor speed depending on the difference variable. It uses a function sending out a high pitched sound as it reads the sensors.
  • The code also has a function I named wall threshold which detects the walls using the distance sensors.
  • 'Direction of wheels' is a function to set the direction based on which wall is detected.
  • If statement for if frontwall == true.

Code: https://drive.google.com/file/d/1L-LepMkA_E6SnfNMQ...