Skip to content

Add 8 LED example. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/74hc595_8_led.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import time
import board
import digitalio
import adafruit_74hc595

latch_pin = digitalio.DigitalInOut(board.D5)
sr = adafruit_74hc595.ShiftRegister74HC595(board.SPI(), latch_pin)

# Create the pin objects in a list
pins = [sr.get_pin(n) for n in range(8)]

while True:
for _ in range(2): # Run the chase animation twice
for enabled_pin in range(len(pins)):
for pin_number, pin in enumerate(pins):
if pin_number == enabled_pin:
pin.value = True
else:
pin.value = False
time.sleep(0.01)
for _ in range(3): # Run the blink animation three times
for pin in pins:
pin.value = True
time.sleep(0.5)
for pin in pins:
pin.value = False
time.sleep(0.5)