73
GPIO.setup(line_pin_middle,GPIO.IN)
GPIO.setup(line_pin_left,GPIO.IN)
def
run():
'''
Read the values of three infrared sensor phototransistors (0 is no line detected, 1 is line detected)
This routine takes the black line on white as an example
'''
status_right = GPIO.input(line_pin_right)
status_middle = GPIO.input(line_pin_middle)
status_left = GPIO.input(line_pin_left)
# Detect if the line hunting module senses the line
if
status_middle == 1:
'''
Control the robot forward
'''
print('forward')
elif
status_left == 1:
'''
Control the robot to turn left
'''
print('left')
elif
status_right == 1:
'''
Control the robot to turn right
'''
print('right')
else:
'''
If the line is not detected, the robot stops, you can also make the robot go backwards
'''
print('stop')
if
__name__ == '__main__':
setup()
while
1:
run()
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?