{:en}

| Buy from US | Buy from CA | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES |
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 2.
Note: in lesson 1, 5 black/white tracking sensors have been installed and connected to Raspberry Pi to prepare for lesson 3.
Note: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.
cd osoyoo-robot/ wget --no-check-certificate http://osoyoo.com/driver/lf-tank.tar.gz
Note: Above commands will download sample code file to osoyoo-robot/lf directory
STEP2: Extract sample code file..
tar -zxvf lf-tank.tar.gz
cd lf

Step 3: 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.
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:
sudo 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.
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
sudo python line_follow.py

After above command is sent to raspberry Pi, your car will start moving along the black track automatically.
{:}{:zh}
前面测试通过了车体安装,电机能够正常运转。在这一课中将告诉大家如何让小车循迹。
step1:下载软件源码
cd osoyoo-robot/ wget --no-check-certificate http://osoyoo.com/driver/lf-tank.tar.gz
step2:解压源码包 lf.tar.gz里面包含了循迹模块测试程序和循迹程序
tar -zxvf lf-tank.tar.gz cd lf
step3:测试循迹模块 循迹模块上有5个黑白循迹探头,每个探头对应一个红色信号灯,没有检测到黑线时候灯亮起;当检测到黑线时候信号灯熄灭,输出端输出一个低电平,5个探头从左往右分别编号为1-5.将循迹模块探头放置在白色背景黑色线上,当对应探头在黑线上时候,终端会输出提示信息:”No.x
is OK!”,同时,信号灯熄灭。例如,3号探头位于黑线上,会打印出”No.3 is OK!”。如果探头位于黑线上,但是终端输出:”No
black line detected!”,说明循迹模块不正常,请检查接线是否正确;探头是否距离黑线太高或太近。
sudo python test.py
如果测试没有问题,就可以运行下面的循迹程序了。如果测试不通过,请检查循迹模块接线是否正确。
将小车放置在事先铺设好的轨道上,轨道要求白色背景黑色线,线宽在10 cm-30 cm之间,轨道尽量平滑,避免铺设转弯处是直角的轨道。运行下面shell命令后,小车将沿着轨道前进。
sudo python line_follow.py
{:}
You must be logged in to post a comment
About the Author