Invert button logic
Per review, not all boards have pull down capability, so swapping the logic!
This commit is contained in:
parent
0fe08ed65f
commit
a50aea4029
3 changed files with 6 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ button_pin = board.D3
|
|||
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
|
||||
button = DigitalInOut(button_pin)
|
||||
button.direction = Direction.INPUT
|
||||
button.pull = Pull.DOWN
|
||||
button.pull = Pull.UP
|
||||
|
||||
solid_blue = Solid(pixels, color=BLUE)
|
||||
solid_red = Solid(pixels, color=RED)
|
||||
|
|
@ -38,7 +38,7 @@ while True:
|
|||
animation_sequence.animate()
|
||||
|
||||
# Pressing the button pauses the animation permanently
|
||||
if button.value:
|
||||
if not button.value:
|
||||
animation_sequence.next()
|
||||
while button.value:
|
||||
time.sleep(0.1) # Used for button debouncing
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ button_pin = board.D3
|
|||
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
|
||||
button = DigitalInOut(button_pin)
|
||||
button.direction = Direction.INPUT
|
||||
button.pull = Pull.DOWN
|
||||
button.pull = Pull.UP
|
||||
|
||||
pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED)
|
||||
|
||||
|
|
@ -34,5 +34,5 @@ while True:
|
|||
pulse_animation.animate()
|
||||
|
||||
# Pressing the button pauses the animation permanently
|
||||
if button.value:
|
||||
if not button.value:
|
||||
pulse_animation.freeze()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ button_pin = board.D3
|
|||
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
|
||||
button = DigitalInOut(button_pin)
|
||||
button.direction = Direction.INPUT
|
||||
button.pull = Pull.DOWN
|
||||
button.pull = Pull.UP
|
||||
|
||||
# Create the animation and freeze it afterwards
|
||||
pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED)
|
||||
|
|
@ -36,5 +36,5 @@ while True:
|
|||
pulse_animation.animate()
|
||||
|
||||
# Pressing the button resumes (or in this case starts) the animation permanently
|
||||
if button.value:
|
||||
if not button.value:
|
||||
pulse_animation.resume()
|
||||
|
|
|
|||
Loading…
Reference in a new issue