Last active
April 5, 2023 18:01
-
-
Save erikvanzijst/df1d182e47e53d519f44574c852a523c to your computer and use it in GitHub Desktop.
Knight Rider LEDs on a Raspberry Pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The code accompanying https://www.youtube.com/watch?v=PsVcLdAyAcU | |
import atexit | |
import time | |
from gpiozero import LEDBoard | |
leds = LEDBoard(2, 3, 4, 17, 27, 22, 10, 9) | |
i = 0 | |
atexit.register(leds.close) | |
while 1: | |
leds.on(i ^ (i >> 3 and 0xf or 0)) | |
i = (i + 1) & 0xf | |
time.sleep(0.1) | |
leds.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment