Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

 

In this tutorial, we will use two OSOYOO tracking sensors to guide the car to move along the black track line in the white ground automatically. The software in this lesson will read data from the tracking sensors and automatically guide the car to move along the black track line in the white ground.

A Line Follower Robot, as the name suggests, is an auto-driving vehicle which follows a black track line printed in white ground. Tracking sensors in the robot keeps checking if the current car location is out of the track. If yes, then car will make a negative movement to draw the robot car back to track.

If you don’t complete the frame of car, please review lesson 1

If you don’t complete the basic wire connection, please review lesson 2

Connection:

Left Tracking Sensor to D7

Right Tracking Sensor to D6

STEP 1:

Download https://osoyoo.com/driver/2022008400/lesson3.zip , unzip it, you will see a folder called lesson3

STEP 2:

Connect UNO R3 board to PC with USB cable, open IDE, choose corresponding board/port for your project.

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to OSOYOO Basic Board for Arduino.

STEP 3:

Click file -> click Open -> choose code “lesson3.ino”, load the code into OSOYOO Basic Board for Arduino, and then upload the sketch to the board.

Notice: Servo Alignment

Please change the default value 90 in the following line as the FRONT value in the option 2 in Step 5 of lesson2. If you align the wheel direction manually as the option 1 in Step 5 of lesson2, please skip this step.

#define FRONT 90        // steering to front

STEP 4:

Adjust the sensitivity of tracking sensor modules.

Turn on and hold the car and adjust the potentiometer on the tracking sensor with cross screwdriver until you get the best sensitivity status: the signal indicate LED light will turn off when sensor is above white ground, and the signal LED will turn on when the sensor is above black track.

how_to_play.png (1150×56)

1.Prepare a black track (the width of the black track is more than 20mm and less than 30mm) in white ground. Please note, the bend angle of track can’t be larger than 30 degree. If the angle is too large, the car will move out of the track.

2. Put the car on the track, turn on the switch of OSOYOO Motor Shield and  the switch of the batter box, the car will move along the black track.
Note: If the car does not move as per above mentioned result, you should check your wire connection of tracking sensor, battery voltage (must over 7.2v).

3. If you want to change the angel of the right or left, please edit the following line of the code and upload the sketch again:

int RIGHT=FRONT-70;
int LEFT=FRONT+70;

5. If you want to change the speed of the car, please revise the following code of the sketch  (Note: the max value is 255)

#define SPEED 190
#define HI_SPEED 220

No. Picture Device Link
1 OSOYOO Basic R3 Board for Arduino Click here to buy
2 OSOYOO Magic I/O Shield for Arduino Click here to buy
3 ESP8266 WIFI Shield Click here to buy
4 HC Module Click here to buy
5 Tracking Sensor Click here to buy
6 OSOYOO Red LED module Click here to buy
7 3 pin 20cm PnP cable Click here to buy
8 Wheel  Click here to buy
9 Servo Click here to buy
10 Motor Click here to buy
11 1Pair 18650 batteries Click here to buy
12 18650 battery box Click here to buy
13 Battery charger Click here to buy
14 K115 Click here to buy
15 K109 Click here to buy
16 K105 Click here to buy
17 K103 Click here to buy
18 B117 Click here to buy
19 B113 Click here to buy
20 B113 Click here to buy
21 B109 Click here to buy
22 B107 Click here to buy
23 B105  Click here to buy
24 B105 Click here to buy
25 B103 Click here to buy
26 B102 Click here to buy
27 B102 Click here to buy
28 X275 Click here to buy
29 X073 Click here to buy
30 X064 Click here to buy
31 X044 Click here to buy
32 L024 Click here to buy
33 L024 Click here to buy
34 PS11 Click here to buy
35 P021 Click here to buy
36 P011 Click here to buy
37 Z005 Click here to buy
38 Z010 Click here to buy
39 L035 Click here to buy
40 LT33 Click here to buy
41 S225 Click here to buy
42 D107 Click here to buy
43 D105 Click here to buy
44 G110 Click here to buy
45 F057 Click here to buy
46 Z2S1 Click here to buy
47 Z2S1 Click here to buy
48 Z121 Click here to buy
49 T220 Click here to buy
50 T112 Click here to buy
51 T008 Click here to buy
52 A04T Click here to buy
53 A040 Click here to buy
54 A050 Click here to buy
55 A070 Click here to buy
56 A160 Click here to buy
57 A02X Click here to buy
58 Q111 Click here to buy
59 PS21 Click here to buy
60 Q112 Click here to buy
61 Q113 Click here to buy
62 Q114 Click here to buy
63 Q115 Click here to buy
64 Z102 Click here to buy
65 Q116 Click here to buy