Skip to content
Open
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
35 changes: 16 additions & 19 deletions circuit-playground-part-1/bike-light/kitt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@

###### Function to Change Color ######
def checkPress(colorIndex):
if cpx.button_a:
colorIndex += 1
if colorIndex > 10:
return 0
return colorIndex
if cpx.button_a:
colorIndex += 1
colorIndex = colorIndex % 10
return colorIndex

###### Function to Change Function ######
def functionPress(functionIndex):
if cpx.button_b:
functionIndex += 1
if functionIndex > 2:
return 0
return functionIndex
if cpx.button_b:
functionIndex += 1
functionIndex = functionIndex % 3
return functionIndex

###### Color and Blinking ######
def blinkLed(colorIndex, d = 0.5, ledIndex = 10, turnOff = True):
Expand Down Expand Up @@ -58,14 +56,13 @@ def kitt(d = 0.1):
time.sleep(d)
return

def rainbowSpin(d = 0.1):
global colorIndex
for x in range(0, 10):
blinkLed(colorIndex, d, x, False)
colorIndex += 1
if colorIndex > 10:
colorIndex = 0
return
def rainbowSpin(d=0.1):
global colorIndex
for x in range(0, 10):
blinkLed(colorIndex, d, x, False)
colorIndex += 1
colorIndex = colorIndex % 10
return

##########################
###### Main Program ######
Expand All @@ -83,4 +80,4 @@ def rainbowSpin(d = 0.1):
rainbowSpin()
else:
# shut it
cpx.pixels.fill((0, 0, 0))
cpx.pixels.fill((0, 0, 0))