Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motor stay on always when .stop function is used #26

Open
AlphaWolf655 opened this issue Jan 5, 2022 · 0 comments
Open

Motor stay on always when .stop function is used #26

AlphaWolf655 opened this issue Jan 5, 2022 · 0 comments

Comments

@AlphaWolf655
Copy link

AlphaWolf655 commented Jan 5, 2022

tried to make it so that if something is infront of my ultrasonic sensor then the motor turns on but as soon as theres nothing infront of it the motor stops but for some reason the motor never stops.

`import RPi.GPIO as GPIO
import time
import PiMotor

GPIO.setwarnings(False)

US1 = PiMotor.Sensor("ULTRASONIC", 40)
m1 = PiMotor.Motor("MOTOR1", 2)

while True:
US1.sonicCheck()
time.sleep(0.5)
if US1.Triggered == True:
print('Starting')
m1.forward(40)
else:
print('Stopping')
m1.stop`

when i run this script and stand infront of the sensor the motor turns on but when i move out the way the motor stays on but it prints "stopping" which means the else part of the if statement is being executed but the motor doesnt stop, the .stop function does work ive tried but for some reason here it doesnt work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant