Micro:bit Line Following Robot

by jose in Circuits > Robots

5551 Views, 19 Favorites, 0 Comments

Micro:bit Line Following Robot

20211101_212135.jpg
Micro:bit Line Following Robot Test

In this instructable, we are going to build a line following robot using a Micro:bit and some other elements.

A line following uses infrared sensors that determine if a surface is white or black, by using multiple of these sensors arranged in a line, we can determine which of them are sensing a black surface (the line) and which of them are measuring a white surface, thus determinating the position of the line drawn on the floor, and based on that the robot decides which direction to go to follow the line.

Supplies

Tools

  • Hot glue
  • Soldering iron and solder
    • Needed to solder the headers of the QTR-8A Sensor array
  • Cutter
  • Needle
  • Pliers
  • Scissors

Electronics

20211101_061852.jpg
20211101_062022.jpg
schem.png
schem_bb.png

We will start by connecting the electronic components using the 2 Mini breadboards, wires, just follow the schematics or use the tables below for the connections of each component

Start with the Voltage regulator circuit, connect the 240 Ohm resistor between the Output and Adjust pins of the LM317T, and connect the 390 Ohm resistor between the Output pin of the LM317T and ground. On the input pin connect the 7.4V of the battery.

The names of the pins of the LM317T voltage regulator are shown in page 2 of the datasheet

These connections were done using F/F Jumper cables, the sensor array generally comes without soldered headers, if that's so then solder them and then connect F/F jumper cables to them

+---------------------+-------------------+
| QTR-8A Sensor array | Connect to        |
+---------------------+-------------------+
| VCC                 | 3.3 V (Regulator) |
+---------------------+-------------------+
| GND                 | GND               |
+---------------------+-------------------+
| 2                   | Micro:bit pin 10  |
+---------------------+-------------------+
| 3                   | Micro:bit pin 4   |
+---------------------+-------------------+
| 4                   | Micro:bit pin 3   |
+---------------------+-------------------+
| 5                   | Micro:bit pin 2   |
+---------------------+-------------------+
| 6                   | Micro:bit pin 1   |
+---------------------+-------------------+
| 7                   | Micro:bit pin 0   |
+---------------------+-------------------+
+--------------------+-------------------+
| L293D              | Connect to        |
+--------------------+-------------------+
| Pin 1 (1,2EN)      | 3.3 V (Regulator) |
| Pin 16 (VCC1)      |                   |
| Pin 9 (3,4EN)      |                   |
+--------------------+-------------------+
| Pin 8 (VCC2)       | 7.4 V (Battery)   |
+--------------------+-------------------+
| Pins 4,5,12,13     | GND               |
+--------------------+-------------------+
| Pin 2 (1A)         | Micro:bit pin 7   |
+--------------------+-------------------+
| Pin 7 (2A)         | Micro:bit pin 8   |
+--------------------+-------------------+
| Pin 10 (3A)        | Micro:bit pin 13  |
+--------------------+-------------------+
| Pin 15 (4A)        | Micro:bit pin 12  |
+--------------------+-------------------+
| Pins 3,6 (1Y, 2Y)  | Right Motor       |
+--------------------+-------------------+
| Pins 11,14 (3Y,4Y) | Left Motor        |
+--------------------+-------------------+

Making the Basic Structure

Structure.png
Structure Components.png
20211101_122053.jpg
20211101_124158.jpg
20211101_125230.jpg
20211101_125950.jpg
20211101_200923.jpg
20211101_201204.jpg
20211101_201638.jpg
20211101_201736.jpg

We are going to cut a piece of cardboard to hold our electronic components, for that draw 3 vertically centered rectangles with the dimensions shown in the picture, and then cut the whole shape.

After that, draw the rectangle that has the cross hatch pattern on the second image, and cut it out.

When that's done, we are going to make some holes to hold the LEDs which will act as some sort of front wheels of the robot, for that, use an LED with straight leads as a guide, and mark 2 points at each short side of the hole you just made (as shown in the pictures)

Now to make the holes, first put the shape on top of another piece of cardboard to not damage the surface underneath, then, with the help of the pliers and the needle, push through the marked points, then lift the cardboard shape and put the needle through each hole.

Mounting the Breadboard and Battery to the Structure

Structure Components.png
20211101_202424.jpg
20211101_202601.jpg
20211101_203202.jpg
20211101_203524.jpg
20211101_203616.jpg

Before the continuing, connect the hot glue gun so that it's heated up when we need to use it later.

We are going to start putting the components on top of the cardboard shape.

The first thing we are going to put on the structure is the breadboards, we can use the peel and stick adhesive beneath them, or put some double-sided tape. If you don't have double sided tape just roll some short pieces of normal tape and put them beneath the breadboards. Stick the breadboards to the structure in the position shown by the first image, it doesn't have to be precise, but what we want is for them to be centered and the bottom breadboard (the blue one) to be touching the edge of the structure.

Done that, we are going to mount the battery using the same procedure, the battery goes just on the front of the breadboard on the top (the green one). Note: Don't press the battery too hard to avoid damaging it

Mounting the Sensors and Motors to the Structure

20211101_204228.jpg
20211101_204641.jpg
20211101_204814.jpg
20211101_204956.jpg
20211101_205014.jpg
20211101_205038.jpg
20211101_210042.jpg
20211101_210129.jpg
20211101_210407.jpg

Now we are going to mount the QTR sensor array. For that cut a strip of tape, around 7CM in length, and then with the sticky side up, put it through the hole in one of the sides, then wrap it like in the picture, so that the sticky side sticks to itself a little bit (around 5mm), do this for the other side too.

Now put the sensor array on top of the hole so that the sensors go through the hole, then secure it with the strips of tape.

For the motors. we are going to use hot glue, just add hot glue to the bottom of the motors and then put them on the corner of the structure.

Mounting the Wheels

20211101_222053.jpg
20211101_222151.jpg
20211101_222305.jpg
20211101_222410.jpg
20211101_222438.jpg
20211101_211304.jpg
20211101_211439.jpg

Now we add the front wheels, for that we are going to use the two short LEDs, stick them through the bottom of the structure on the holes previously made (if the leads don't seem to go through, put the needle again through the bottom and then try again). The LEDs should be touching the cardboard, afte that, on the top side, bend the leads to secure them.

For the back wheels, just put the wheel of each motor in the axle, try holding the motor while doing so instead of the whole structure to prevent ripping the motor off the structure.

Uploading the Code

20211101_212135.jpg

The mechanical part is done, now that's left is uploading the code. for that we are using Microsoft's MakeCode for Micro:bit

The code can be found here, just connect the micro:bit through usb and upload the code

Test!

Micro:bit Line Following Robot Test

I happen to have a track to test the robot, but you can make your own with a large piece of bond paper and electrical tape.

To start the robot press the A button, and to stop it press the B button