Tracking module (applied to the car)

1.1 Use of tracking module

The infrared emitting diode of the TCRT5000 sensor continuously emits infrared rays

When the emitted infrared rays are not reflected back or are reflected back but not strong enough,

The infrared receiving tube is always in the off state. At this time, the output terminal of the module is at a high level, and the indicator diode is always in the off state.

When the detected object appears within the detection range, the infrared rays are reflected back and the intensity is large enough, and the infrared receiving tube is saturated.

At this time, the output terminal of the module is low level, indicating that the diode is lit

The summary is just one sentence, if there is no reflection back, D0 outputs high level, and the light is off

                                         TCRT5000 physical map

 1.2 Principle of tracking car

Because black has a strong absorption capacity, when the infrared rays emitted by the tracking module hit the black line, the infrared rays will be absorbed by the black line, causing the phototransistor on the tracking module to be turned off, and an LED on the module is off at this time. When no black wire is detected, the two LEDs on the module light up.

The summary is one sentence, the black line is sensed, D0 outputs a high level, and the light is turned off

 Attach the basic car movement code (front, back, left, right)

 motor driver code

#include "reg52.h"
sbit RightCon1A=P3^2;
sbit RightCon1B=P3^3;

sbit LeftCon1A=P3^4;
sbit LeftCon1B=P3^5;
void goForward()
{
	LeftCon1A=1;
	LeftCon1B=0;
	RightCon1A=1;
	RightCon1B=0;
}
void goBack()
{
	LeftCon1A=0;
	LeftCon1B=1;
	RightCon1A=0;
	RightCon1B=1;
}
void goLeft()
{
	LeftCon1A=0;
	LeftCon1B=0;
	RightCon1A=1;
	RightCon1B=0;
}
void goRight()
{
	LeftCon1A=1;
	LeftCon1B=0;
	RightCon1A=0;
	RightCon1B=0;
}
void stop()
{
	LeftCon1A=0;
	LeftCon1B=0;
	RightCon1A=0;
	RightCon1B=0;
}

Guess you like

Origin blog.csdn.net/weixin_62599865/article/details/130517132
Recommended