Hallo,
das Programm
[PHP]
import RPi.GPIO as GPIO
BounceTime=50 #[ms]
GPIO.setmode(GPIO.BCM)
switm=[23,24] # GPIOs Taster
for i in switm :
GPIO.setup(i,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
print ('setup:',i)
def ButtonPressed(value) :
print ('ButtonPressed @ GPIO # :',value)
"""for i in range(len(switm)) : # geht nicht
GPIO.add_event_detect(switm[i], GPIO.BOTH, callback=lambda x: ButtonPressed(switm[i]), bouncetime=BounceTime)
"""
GPIO.add_event_detect(switm[0], GPIO.BOTH, callback=lambda x: ButtonPressed(switm[0]), bouncetime=BounceTime)
GPIO.add_event_detect(switm[1], GPIO.BOTH, callback=lambda x: ButtonPressed(switm[1]), bouncetime=BounceTime)
[/PHP]
funktioniert.
ABER warum funktioniert der eleganter Weg (Auskommentiert) nicht. Ich hätte eine liste von solchen Funktionen zu starten.
Bitte um eine "Umweg"
Danke
Gottfried