Motor start condition bug fix

This commit is contained in:
LEYAO LI 2021-04-04 16:58:29 -04:00
parent 05d2e90880
commit fa4f130793

View file

@ -173,10 +173,10 @@ if __name__=="__main__":
# get distance data from distance sensor # get distance data from distance sensor
dist = car.distance() dist = car.distance()
print ("Measured Distance = %.1f cm" % dist) #print ("Measured Distance = %.1f cm" % dist)
# Turn on motor if get sensor signal # Turn on motor if get sensor signal
if ((motorSignal=="on" or dist>15) and car.motorStop): if ((motorSignal=="on" and dist>15) and car.motorStop):
car.start_motor() car.start_motor()
elif ((motorSignal=="off" or dist<=10) and not car.motorStop): elif ((motorSignal=="off" or dist<=10) and not car.motorStop):
# Stop the motor if the vehicle is too close to the item at front as well # Stop the motor if the vehicle is too close to the item at front as well