User Manual
49
for pin in LedPins # Assign the element in pins list to pin variable one by one. In
GPIO.setup (pin, GPIO.OUT), set the pins in list as output one by one.
GPIO.output(pin, GPIO.LOW) # Set each element in the pins list as low level to
light up the LEDs
leds[LedPins.index(pin)] = 0 # Show which LED is on
time.sleep(0.1) # wait for 0.1s
GPIO.output(pin, GPIO.HIGH)) # After delaying, set it as high level to light up or
turn off the LED.
leds[LedPins.index(pin)] = '-' # Show the led is off
You will see the eight LEDs lighten up one by one, and then dim in turn.
Further Exploration
You can write the blinking effects of LEDs in an array. I f you want to use one of these effects,
you can call it in the main() function directly.
SunFounder