I have this script which runs a motor until a button is released. It was working fine up until making some changes to the setup earlier but now the motor doesn't stop when the button is released -
import RPi.GPIO as GPIO import time import os from time import sleep GPIO.setmode(GPIO.BOARD) GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(11,GPIO.OUT) GPIO.setup(13,GPIO.OUT) GPIO.setup(15,GPIO.OUT) print "Screen up" GPIO.output(11,GPIO.HIGH) GPIO.output(13,GPIO.LOW) GPIO.output(15,GPIO.HIGH) while True: input_state = GPIO.input(10) if input_state == True: GPIO.output(15,GPIO.LOW) time.sleep(1) exit() message = input("Press enter to quit\n\n") GPIO.cleanup()
I've tested the button with the following simple button script and it seems to be working fine so I'm very puzzled as to why the motor script isn't now working.
from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(10,GPIO.IN,pull_up_down=GPIO.PUD_UP) while(1): if GPIO.input(10)==0: print "Button pressed" sleep(1)