Welcome to 8-Channel Tracking Module repository
IO method
Raspberry Pi - IO method
Raspberry Pi - IO methodExperimental preparationExperimental purposeExperimental wiringExperimental steps and phenomenaExperimental source code
Experimental preparation
Raspberry Pi motherboard
8-channel line patrol module
Several Dupont cables
The Raspberry Pi board needs to download the IO communication source code provided in the document
Experimental purpose
The content of this experiment is mainly to use the Raspberry Pi main control to receive the data of the 8-channel line patrol module through IO.
Experimental wiring
| Raspberry Pi | 8-channel line patrol module |
|---|---|
| GPIO.21 | x1 |
| GPIO.22 | x2 |
| GPIO.23 | x3 |
| GPIO.24 | x4 |
| GPIO.25 | x5 |
| GPIO.27 | x6 |
| GPIO.28 | x7 |
| GPIO.29 | x8 |
| 5V | 5V |
| GND | GND |


As shown in the figure:

Experimental steps and phenomena
After connecting the wires, do not power on for wiring, power off for wiring Run the script
python3 IR_IO.py
Experimental source code
xxxxxxxxxxtry: while True: # Read pin level pin_state_x1 = GPIO.input(x1) pin_state_x2 = GPIO.input(x2) pin_state_x3 = GPIO.input(x3) pin_state_x4 = GPIO.input(x4) pin_state_x5 = GPIO.input(x5) pin_state_x6 = GPIO.input(x6) pin_state_x7 = GPIO.input(x7) pin_state_x8 = GPIO.input(x8) print("x1:"+str(pin_state_x1)+" x2:"+str(pin_state_x2)+" x3:"+str(pin_state_x3)+" x4:"+str(pin_state_x4)+" x5:"+str(pin_state_x5)+" x6:"+str(pin_state_x6)+" x7:"+str(pin_state_x7)+" x8:"+str(pin_state_x8)) # Wait for a while time.sleep(1)finally: # Clean up GPIO settings GPIO.cleanup()The main function of the source code is very simple. It reads the probe pins of 8 patrol lines through IO and prints them out.