Toggle Navigation
Hatchery
Eggs
Knightrider - with speed control
knightrider.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
knightrider.py
raw
Content
""" Knight Rider Use left and right button to make KITT more ore less enthusiastic Written by: Anykey """ import leds import htmlcolor import buttons import utime speed = 0.05 def setPos(pos): for L in range(0, 11): if L == pos: leds.prep(L, htmlcolor.RED) else: leds.prep(L, htmlcolor.BLACK) leds.update() def CheckButton(): global speed pressed = buttons.read( buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT ) if pressed & buttons.BOTTOM_LEFT != 0: speed = speed + 0.01 if pressed & buttons.BOTTOM_RIGHT != 0: if speed > 0.01: speed = speed - 0.01 while True: for P in range(0, 11): setPos(P) CheckButton() utime.sleep(speed) P = P - 1 while P > 0: setPos(P) CheckButton() utime.sleep(speed) P = P -1