This is my first time using a forum so sorry if my educate is not great, but i could use some help. I'm trying to have my program give a single output for a single input within a set of loops. If manual button 1 (button_state_man1) is pressed then as long as manual button 3 (button_state_man3) is not pressed anytime you press button 1 again, "moving up" is printed once for every press or "moving down" is printed for every press of button 2 (button_state_man2). The problem I have is that in the current code if button 1 is pressed at all "moving up" prints infinitely. If I add a break/continue it returns to the first if statement without button 3 being pressed. Can anyone help me in this matter?
while True:
button_state_man1 = GPIO.input(BUTTON_MAN1)
button_state_man2 = GPIO.input(BUTTON_MAN2)
button_state_man3 = GPIO.input(BUTTON_MAN3)
if button_state_man1 == 0:
print('1')
sleep(delay2)
while not button_state_man3 == 0:
if button_state_man1 == 0:
print('moving up')
for x in range(step_count):
GPIO.output(DIR, 1)
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP, GPIO.LOW)
sleep(delay)
if button_state_man2 == 0:
print('moving down')
for x in range(step_count):
GPIO.output(DIR, 0)
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP, GPIO.LOW)
sleep(delay)
