Objective:
In this lesson, we use our Raspberry Pi robot car to automatically drive along a black line in white ground . We will use five IR tracking sensors to detect the line.
Hardware Installation:
You must complete Lesson 1 basic frame work installation as per following link:
OSOYOO Raspberry Pi V2.0 car lesson 1: Basic framework installation and L298N board
You also need connect five IR tracking sensors to following GPIO port:
sensor# | location | GPIO# | Physical Pin# |
sensor 1 | Far Left | GPIO5 | 29 |
sensor 2 | 2nd left | GPIO6 | 31 |
sensor 3 | middle | GPIO13 | 33 |
sensor 4 | 2nd right | GPIO19 | 35 |
sensor 5 | far right | GPIO26 | 37 |
you can check the GPIO pin location in following graph:
You might need to 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 on when sensor is above white ground, and the signal LED will turn off when the sensor is above black track.
Software Installation:
Download the python code by typing following command in your Raspberry Pi terminal:
wget http://osoyoo.com/driver/picar/picar-line-tracking.py
Turn on the battery of your car and put the car on the black track line:
Now you can run the line tracking python program by typing following command:
python picar-line-tracking.py
Your car will move along the black track line.
DownLoad Url osoyoo.com