Skip to content

Commit a50aea4

Browse files
committed
Invert button logic
Per review, not all boards have pull down capability, so swapping the logic!
1 parent 0fe08ed commit a50aea4

3 files changed

+6
-6
lines changed

examples/led_animation_cycle_animations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
2929
button = DigitalInOut(button_pin)
3030
button.direction = Direction.INPUT
31-
button.pull = Pull.DOWN
31+
button.pull = Pull.UP
3232

3333
solid_blue = Solid(pixels, color=BLUE)
3434
solid_red = Solid(pixels, color=RED)
@@ -38,7 +38,7 @@
3838
animation_sequence.animate()
3939

4040
# Pressing the button pauses the animation permanently
41-
if button.value:
41+
if not button.value:
4242
animation_sequence.next()
4343
while button.value:
4444
time.sleep(0.1) # Used for button debouncing

examples/led_animation_freeze_animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
2727
button = DigitalInOut(button_pin)
2828
button.direction = Direction.INPUT
29-
button.pull = Pull.DOWN
29+
button.pull = Pull.UP
3030

3131
pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED)
3232

3333
while True:
3434
pulse_animation.animate()
3535

3636
# Pressing the button pauses the animation permanently
37-
if button.value:
37+
if not button.value:
3838
pulse_animation.freeze()

examples/led_animation_resume_animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
2727
button = DigitalInOut(button_pin)
2828
button.direction = Direction.INPUT
29-
button.pull = Pull.DOWN
29+
button.pull = Pull.UP
3030

3131
# Create the animation and freeze it afterwards
3232
pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED)
@@ -36,5 +36,5 @@
3636
pulse_animation.animate()
3737

3838
# Pressing the button resumes (or in this case starts) the animation permanently
39-
if button.value:
39+
if not button.value:
4040
pulse_animation.resume()

0 commit comments

Comments
 (0)