TCRT5000 is an infrared transmitter and receiver, which continuously emits and receives infrared rays.
1. Pulse data sampling of watt-hour meter
2. Facsimile paper shredder paper detection
3. Obstacle detection
4. Black and white line detection
The module has 4 pins, namely VCC, GND, A0, and D0. A0 is the analog signal output, and D0 is the TTL level output. Using TCRT5000 is mainly used for tracking, only need to connect VCC, GND, D0.
(1) Working voltage 3.3V-5V
(2) The potentiometer on the module is used to adjust the sensitivity
(3) Detection reflection distance: 1mm~25mm applicable
(4) Output form: digital switch output (0 and 1)
(5) Equipped with fixing bolt holes for easy installation
(6) Small board PCB size: 3.2cm x 1.4cm
(7) Use wide voltage LM393 comparator
The principle of TCRT5000 tracking module
The tracking principle is very simple. The module is equipped with an output indicator, and some modules also have a power indicator. We mainly focus on the output indicator. The infrared transmitter always emits infrared rays, and the infrared rays are received after being emitted. At this time, the output is low and the output indicator light is on.
Black does not reflect infrared rays, which means that when the tracking module encounters a black line, the module outputs a high level and the output indicator light goes out.
Of course, in addition to the black line going out, when the distance is too far, the infrared reflection cannot be detected, and the indicator light will also go out at this time.
Then if you want to track, the module should be close to the ground. Make sure that the indicator light stays on when there is no black line. Once the indicator light goes out, it means you have encountered the black line.
The application of TCRT5000 tracking module
After understanding the principle, the code implementation is very simple, which is equivalent to button detection.
The following is implemented with STM32 firmware library V3.5.
The following is the source file. Note that it should be set to the pull-down input mode. The input mode does not need to configure the speed.
GPIO_InitTypeStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6;
GPIO_InitTypeStructure.GPIO_Mode = GPIO_Mode_IPD;
Below is the header file
#define Tracking_DO GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_6)
It is enough to judge whether Tracking_DO is 1 after initialization in the mian function
if(Tracking_DO == 1)
/*Write related applications here*/