Sep-27-2021, 03:15 PM
(This post was last modified: Sep-27-2021, 03:15 PM by deanhystad.)
I don't think you need a function. I would generate the dictionary like this.
Map your LED "names" to pin numbers.
Map your LED "names" to pin numbers.
leds = {"in_ledS":17, "in_ledXL":18, "in_ledXXL":22, "in_ledS1":23, "in_ledS2":4}Map your LED "names" to LED status
led_state = {name:GPIO.input(pin) for name, pin in leds.items()}Or if you got a dictionary of status that you want to apply.
for led, state in led_state.items(): GPIO.output(leds[led], state)