My first thought is that the sleep time is messed up, and somehow preventing it from registering turns, but I've tried both larger and smaller values and have as bad, if not worse, results. The pins are set the way they are because I was following a tutorial so I'm not sure if that's the optimal way to do it.
Code: Select all
minute = 0 sec = 0 clk = 13 dt = 19 sw = 6 GPIO.setmode(GPIO.BCM) GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(sw, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) clk_last_state = GPIO.input(clk) try: while True: clk_state = GPIO.input(clk) dt_state = GPIO.input(dt) sw_state = GPIO.input(sw) if clk_state != clk_last_state: if dt_state != clk_state: value += 1 if sec < 45: sec += 15 else: sec = 0 minute += 1 else: value -= 1 if sec > 0: sec -= 15 else: sec = 45 if minute > 0: minute -= 1 clk_last_state = clk_state display.display(package(minute,sec)) if sw_state != 1: motor.start_motor((60*minute) + (sec)) minute = 0 sec = 0 sleep(.01) finally: GPIO.cleanup()
Any help y'all can provide would be extremely appreciated, thanks!