Skip to content

Commit d8aa99c

Browse files
authored
Merge pull request #12 from kattni/add-8-led-example
Add 8 LED example.
2 parents eb93891 + 8f335c9 commit d8aa99c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/74hc595_8_led.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
import board
3+
import digitalio
4+
import adafruit_74hc595
5+
6+
latch_pin = digitalio.DigitalInOut(board.D5)
7+
sr = adafruit_74hc595.ShiftRegister74HC595(board.SPI(), latch_pin)
8+
9+
# Create the pin objects in a list
10+
pins = [sr.get_pin(n) for n in range(8)]
11+
12+
while True:
13+
for _ in range(2): # Run the chase animation twice
14+
for enabled_pin in range(len(pins)):
15+
for pin_number, pin in enumerate(pins):
16+
if pin_number == enabled_pin:
17+
pin.value = True
18+
else:
19+
pin.value = False
20+
time.sleep(0.01)
21+
for _ in range(3): # Run the blink animation three times
22+
for pin in pins:
23+
pin.value = True
24+
time.sleep(0.5)
25+
for pin in pins:
26+
pin.value = False
27+
time.sleep(0.5)

0 commit comments

Comments
 (0)