Ich will am Raspberry Zero einen Taster auslesen, der an den GPIOs angeschlossen ist. Das funktioniert auch ganz gut mit folgendem Code:
Code: Alles auswählen
TASTER = 20
AUSGANG = 15
GPIO.setup(TASTER, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(AUSGANG, GPIO.OUT)
while True:
tasterStatus = GPIO.input(TASTER)
if ((tasterStatus) == False):
print ("Test")


Code: Alles auswählen
TASTER = 20
AUSGANG = 15
GPIO.setup(TASTER, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(AUSGANG, GPIO.OUT)
def main():
while True:
tasterStatus = GPIO.input(TASTER)
if ((tasterStatus) == False):
print ("Test")
while True:
taster = GPIO.input(TASTER)
if ((taster) == False):
time.sleep(.0001)
else: return main
Kann mir bitte jemand helfen wie ich das Script schreiben muss!
PS: Bitte keine Kommentare alla "Benutze Google", ich habe bereits eine halbe Ewigkeit "gegooglet"!

Vielen Dank schonmal im Voraus
MfG Jakob
