I am stuck on this work related project. What I am trying to accomplish is, after a specific amount of button presses, I want my program to end. I am thinking along the lines of a loop.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)
Max_Presses = 100
button_pressed = 0
def button_pressed():
return input_state()
while button_pressed < Max_Presses:
print 'still going'
if button_pressed():
button_pressed += 1