Hi all,
first of all i want let you know, that i´m a beginner in coding. So sorry, if there is a bad question but i need some help to move forward with my "simple" project.
I have a neopixel strip (10 LEDs) connected with pin D12 and a pushbutton with D9. While the pushbutton is pressed, pixels shall blink in RED. If not pressed, pixels shall light up in GREEN.
The code is simple and it works fine:
import board
import neopixel
from digitalio import DigitalInOut, Pull
import adafruit_led_animation.animation.blink as blink_animation
import adafruit_led_animation.color as color
while True:
if button_in.value:
pixels.fill(color.GREEN)
pixels.show()
else:
blink.animate()`
```py
Now i want to modify the pushbutton: If the button is pressed once, pixels shall light up in GREEN. If the button is pressed again, the stripe shall blink as long as the button is pressed again. I tried it with debouncing and the following code is based on the code of the video from Prof G. --> https://www.youtube.com/watch?v=tjg4R-P88q0&list=PL9VJ9OpT-IPSsQUWqQcNrVJqy4LhBjPX2&index=43YouTubeJohn GallaugherHelp My Pico Button Doesn't Work! Fix multiple press reporting w/Bl...
Makers often learn button basics, only to see their buttons fail when seemingly properly set up and coded. This can be incredibly frustrating. This lesson shows how button events are registered, why problems occur, and how to solve them with a while / pass blocking statement, and with debouncing techniques using the adafruit_debouncer library. W...