File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 2222pixels = neopixel .NeoPixel (
2323 neo_pin , pixel_count , brightness = .4 , auto_write = False )
2424
25- oldstate = True # counting touch sensor button pushes
25+ oldstate = False # counting touch sensor button pushes
2626showcolor = 0 # color mode for cycling
2727
28- # initialize capacitive touch input
28+ # initialize external capacitive touch pad (active high)
2929button = digitalio .DigitalInOut (touch_pin )
3030button .direction = digitalio .Direction .INPUT
3131button .pull = digitalio .Pull .UP
8383 # get the current button state
8484 newstate = button .value
8585
86- # Check if state changed from high to low (button press).
86+ # Check if state changed from low to high (button/touchpad press).
8787 if newstate and not oldstate :
88- # Short delay to debounce button.
89- time .sleep (0.020 )
90-
91- # Check if button is still low after debounce.
92- newstate = button .value
93-
94- if not newstate :
88+ # cycle to next color
9589 showcolor += 1
9690
97- if showcolor > 4 :
98- showcolor = 0
91+ # limit the cycle to the 5 colors
92+ if showcolor > 4 :
93+ showcolor = 0
94+
95+ # give feedback to the REPL to debug the touch pad
96+ # print("Color:", showcolor)
9997
10098 # Set the last button state to the old state.
10199 oldstate = newstate
You can’t perform that action at this time.
0 commit comments