def initGPIO():
global p, q, a, b
#use physical pin numbering
GPIO.setmode(GPIO.BOARD)
#set up digital line detectors as inputs
GPIO.setup(lineRight, GPIO.IN) # Right line sensor
GPIO.setup(lineLeft, GPIO.IN) # Left line sensor
#use pwm on inputs so motors don't go too fast
GPIO.setup(L1, GPIO.OUT)
p = GPIO.PWM(L1, 20)
p.start(0)
GPIO.setup(L2, GPIO.OUT)
q = GPIO.PWM(L2, 20)
q.start(0)
GPIO.setup(R1, GPIO.OUT)
a = GPIO.PWM(R1, 20)
a.start(0)
GPIO.setup(R2, GPIO.OUT)
b = GPIO.PWM(R2, 20)
b.start(0)
threadC = threading.Thread(target=wheelCount)
threadC.start()
# spinLeft(speed): Sets motors to turn opposite directions at speed. 0 <= speed <= 100
评论列表
文章目录