Four-way tracking module:Read status (GPIO)

The tutorial demonstrates the serial port and OLED display of the status of each indicator light of the four-way line patrol module.

Hardware connection

image-20240825212623009

Since we have configured a special connection line, we only need to install it to the corresponding interface:

Four-way line patrol module corresponding LEDFour-way line patrol moduleDevelopment board
 VCC5V/3.3V
L1X1PC4
L2X2PC5
L3X3PB0
L4X4PB1
 GNDGND

Control principle

By reading the X1, X2, X3, and X4 interface levels of the four-way tracking module, it is determined whether the black line is detected and where the black line is located.

1

Black line detected

Light on → The corresponding interface of the four-way patrol module outputs a low level;

White line detected

Light off → The corresponding interface of the four-way patrol module outputs a high level.

Software Configuration

Pin Definition

Main Control ChipPinMain Function (After Reset)Default Multiplexing FunctionRedefine Function
STM32F103RCT6PC4PC4ADC12_IN14 
STM32F103RCT6PC5PC5ADC12_IN15 
STM32F103RCT6PB0PB0ADC12_IN8/TIM3_CH3/TIM8_CH2NTIM1_CH2N
STM32F103RCT6PB1PB1ADC12_IN9/TIM3_CH4/TIM8_CH3NTIM1_CH3N

Software code

Since the default function of the pin is the normal IO pin function, we need to use the default multiplexing function.

Control function

The tutorial only briefly introduces the code, you can open the project source code to read it in detail.

irtracking_init

Experimental phenomenon

The IRtracking.hex file generated by the project compilation is located in the OBJ folder of the IRtracking project. Find the IRtracking.hex file corresponding to the project and use the FlyMcu software to download the program to the development board.

After the program is successfully downloaded: the serial port prints and the OLED displays the X1, X2, X3, and X4 interface levels of the four-way tracking module.

image-20240827180702510