Skip to content

Instantly share code, notes, and snippets.

@erikvanzijst
Last active April 5, 2023 18:01
Show Gist options
  • Save erikvanzijst/df1d182e47e53d519f44574c852a523c to your computer and use it in GitHub Desktop.
Save erikvanzijst/df1d182e47e53d519f44574c852a523c to your computer and use it in GitHub Desktop.
Knight Rider LEDs on a Raspberry Pi
# 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