How to Make a Line Following Robot Using Rpi 3

In this tutorial, you will learn to build a line-following robot buggy so it can whiz around a track with ease.

Step 1: Assemble Your Materials

Some of the materials shown in the picture are used to make most buggy's from scratch. However, this tutorial will not cover the procedure on how to make a chassis or a model for your buggy or how to solder wires to your motors. If you wish to do so, here are all of the materials you will need:

  • Raspberry Pi 3
  • Motor controller board
  • A breadboard
  • A T-cobbler +
  • 2 12V DC motors
  • 2 wheels
  • 1 AA battery holder (for 4 AA batteries)
  • 4 AA batteries
  • Jumper wires
  • A USB Battery pack
  • Screw driver
  • Soldering iron and solder
  • Wire strippers
  • Small cardboard or plastic box and glue/tape
  • 2 line sensors
  • 8 female-to-female jumper leads
  • 4 male-to-male jumper leads
  • Insulating tape

Step 2: Assembling the Motor Board

Assuming that you have set up your motors, You will need to connect the motors to the H-bridge board. For this you will require a small screwdriver. You will now need to connect the motors to the board. For this you will need a small screwdriver

Using a screwdriver, loosen the screws in the terminal blocks. Insert the stripped ends of wire into the terminal blocks. Tighten the screws so they are held firmly by the terminal blocks.

Step 3: Powering Your Motor

The motors require more power than the Rpi can provide. Therefore, you have to use 4 AA batteries to power them.

Loosen the screws in the terminal blocks labeled VCC, GND, and 5V. Take the AA battery holder and insert the red wire into the VCC terminal block. The black wire goes into the GND block. It is important that you get this the correct way around.

Tighten the screws so that the wires are held firmly in place.

Step 4: Connecting Your Motor to the Rpi

The board used in this project needs to be wired to the Raspberry Pi. Other boards may connect differently, and some boards can simply be placed onto the Raspberry Pi GPIO pins as a HAT.

On the board used here there are pins labeled In1, In2, In3, and In4, as well as two GND pins. Which GPIO pins on your Pi that you use is up to you; in this project, GPIO 7, 8, 9, and 10 have been used. If you have a board that don't have the GND pins, you can use the GND pins from the Rpi to achieve the same results. If you have to do this, plug in the GND wire into the same terminal block as the black wire from the battery pack.

Use the T-cobbler + to connect the breadboard and Rpi.

Use five male-to-male jumper leads to connect to the breadboard.

  • In1 --> GPIO 7
  • In2 --> GPIO 8
  • In3 --> GPIO 9
  • In4 --> GPIO 10

Step 5: Prepare the Connectors

Your first step will be to connect your line sensors to your buggy. Normally, the type of line sensor used in this tutorial needs to be connected to a 3V3 pin, but you’re going to run two sensors via the same power pin, so you’ll attach both of them to a 5V pin.

Take three of your female-to-female jumper leads, remove a connector from each end, and then strip the plastic sheath to reveal about a centimeter of the multi-core wire beneath. Take the three jumper leads and twist their multi-core wires together. Then use a soldering iron to bond the leads. Cover the join of the leads with a small amount of insulating tape.

Repeat the entire process with another three female-to-female jumper leads.

Step 6: Connect the Line Sensors

Each line sensor has three pins: VCC for power, GND for ground, and DO for digital out.

Take one of your soldered-together three-wire jumper leads, and connect two of its ends to the VCC pin on each of the two sensors.

Take the second of your soldered jumper leads, and connect two ends to the GND pin on each line sensor.

Take your remaining two single jumper leads and connect each one to the DO pin on each line sensors.

Now connect the VCC pins of both line sensors to a 5V pin on your Raspberry Pi, and the GND pins of the sensors to a GND pin on your Raspberry Pi. Each of the two DO pins can be connected to any numbered GPIO pin. In this example, pins GPIO 17 and GPIO 27 are used.

Step 7: Test the Line Sensors

This is a very simple step. Your line sensor has an LED on it that when powered, remains on. However, once you expose it to a dark line, they go off. This should be the case for your line sensor.

If you think it's too sensitive, use a screwdriver and tune it through it's potentiometer. Tune it towards your satisfaction.

Step 8: Inserting the Program Into Python

Insert these lines of code and running it, you should get a robot that can go perfectly on a track.

Share

    Recommendations

    • Organization Contest

      Organization Contest
    • Remix Contest

      Remix Contest
    • Epilog X Contest

      Epilog X Contest

    Discussions

    0
    None

    Cool robot. Do you have any video clips of this in operation.