Authorized Online Retailers

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

Objective

In this lesson, we will use black/white tracking sensors to guide robot car to trace a black track in the white ground. If you have not completed installation in Lesson 1, please review Lesson 1. (Note: in lesson 1, 5 black/white tracking sensors have been installed and connected to Raspberry Pi to prepare for lesson 2)

top

 

Parts and Devices

Device

Picture
Qty.

Accessories

Raspberry Pi 3 Board
(Not in Package)
1 M2.5*5 Plastic Screw x 4 M2.5 Plastic Nut x 4 M2.5*5+6 Plastic Pillar x 4
OSOYOO Model-Pi Motor Driver Module
1 M3*35 Copper Pillar x4 M3*10 Screw x4 M3 Nut x4 M3 Rubber Ring x4
PCA9685 compatible module
1
M2.5*5 Plastic Screw x 4 M2.5 Plastic Nut x 4 M2.5*5+6 Plastic Pillar x 4
Camera with mount holder
1
M3*10 Screw x2 M3 Nut x 2
Voltage Meter
1
M2.5*5 Plastic Screw x 2 M2.5 Plastic Nut x 2 M2.5*5+6 Plastic Pillar x 2
Tracking Sensor Module
5
M2.5*5 Plastic Screw x 5 M2.5 Plastic Nut x 5 M2.5*5+6 Plastic Pillar x 5
Car Chassis
1
M3*55 Copper Pillar x4 M3*10 Screw x4 M3 Nut x4 M3 Rubber Ring x4
Motors with wires
2

Metal Motor Holders x2

Wheels
2
Universal Wheel
1 M3*10 Screw x2 M3 nut x2 M3 Rubber Ring x2
18650 Battery Box with 2Pin connectors
1 M3*10 Screw x 4 M3*10 Nut x 4
Metal Motor Holders
2
SD Card Reader
1
16GB TF card
1
Phillips Screwdriver
1
Slot Type Screwdriver
1
M3*55 Pillars
M3*30 Pillars
M3 Washers x3
4
M3*10 Screw M3*10 Nut
20
M2.5*5 Plastic Screw M2.5 Plastic Nut M2.5*5+6 Plastic Pillar
20
HDMI to HDMI Cable
1
L USB port to Micro USB port cable
1

Connect Model-Pi Motor Driver Board with Raspberry Pi board

Camera cable
1

Connect Camera with Raspberry Pi board

5Pin 20cm Jumper wire 1 Connect 5 tracking sensor modules with Raspberry Pi board
4Pin 20cm jumper wire 1 Connect PCA9685 compatible module with Raspberry Pi board
2Pin 20cm jumper wire 1 Connect PCA9685 compatible module with Raspberry Pi board
3pin 15cm jumper wire 1 Connect voltage meter with Model-Pi motor driver board
4Pin 10cm jumper wire 1 Connect PCA9685 compatible module with Model-Pi motor driver board
2pin x10cm jumper wire 1 Connect PCA9685 compatible module with Model-Pi motor driver board
1 to 5pin female jumper wire 2 Connect 5 tracking sensor modules with PCA9685 compatible module
Cable Tie 10
Black electrician tape 1

top

 

Hardware Installation

If you don't install 5 tracking sensor modules in lesson1, please install and connect these modules as following pictures. If you have already installed and connected these, please skip this step.

top

 

Software Installation

Note: 1. if you use our image as OS system as lesson1, please skip Software Installation and go to Step2 to adjust the sensitivity of tracking sensor module or the step "test tracking line" 2. Please keep the raspberry Pi on power when using SSH to send command to Raspberry Pi terminal remotely. Step 1:Download line-tracking sample code with following terminal command(skip this step if your micro SD card has pre-installed Osoyoo Robot Image): cd ~/osoyoo-robot/ wget http://osoyoo.com/driver/lf.tar.gz tar -zxvf lf.tar.gz Note: Above commands will download sample code file to osoyoo-robot/lf directory Step 2: Test Black/White Tracking sensors There are 5 black/white tracking sensors in the forehead of the car. Each sensor has two LED lights . The red LED indicates power. The green LED indicates black/white. When black is detected, Green LED will turn off and a "1" will be sent to Raspberry Pi GPIO pin, otherwise LED will ON and a "0" will be sent. * To make sensors working properly, you need use a screw driver to adjust the sensitivity screw on each sensor and make sure Green LED will ON when it is over White and Off when it is over Black. If you want to learn more about adjust tracking module, please follow the next vedio:

Following python code and experiment will tell you if the sensors are installed correctly. First, put a 2 cm black track on white ground, then put your car over the track and turn on battery. Next, use SSH to connect your Raspberry Pi remotely from your PC(use Putty if you are using Windows), and type following terminal command: cd ~/osoyoo-robot/lf python test.py When your put the first sensor(from right) on the black track, the green LED will turn off and your will see Putty terminal window show 00001 as following:

This means Raspberry Pi detected WHITE(0) from 4 sensors in the left and Black(1) from the right edge sensor. You can change the position of the black track from right to left sensors one by one and make the result change from 00001 to 00010,00100,01000,10000.If your result is not showed as above, you might need to double check if the sensor sensitivity and connection to the Pi is correct.

top

 

Testing line tracking

First, make a black track on white ground. The track can be round or curve , but the turning angle of each curve should not be too sharp. We suggest user use 2cm width black tape sticking on white ceramic tile and make a nice track. Next put your car over the track and turn on the power switch on battery box. Last, use SSH to connect Raspberry Pi through your PC and typing following commands: cd ~/osoyoo-robot/lf python line_follow.py

After above command is sent to raspberry Pi, your car will start moving along the black track automatically.

top