File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ """CircuitPython Digital Input example - Blinking a built-in NeoPixel LED using a button switch.
2
+
3
+ Update BUTTON_PIN to the pin to which you have connected the button (in the case of an external
4
+ button), or to the pin connected to the built-in button (in the case of boards with built-in
5
+ buttons).
6
+
7
+ For example:
8
+ If you connected a button switch to D1, change BUTTON_PIN to D1.
9
+ If using a QT Py RP2040, to use button A, change BUTTON_PIN to BUTTON.
10
+ """
11
+ import board
12
+ import digitalio
13
+ import neopixel
14
+
15
+ pixel = neopixel .NeoPixel (board .NEOPIXEL , 1 )
16
+
17
+ button = digitalio .DigitalInOut (board .BUTTON_PIN )
18
+ button .switch_to_input (pull = digitalio .Pull .UP )
19
+
20
+ while True :
21
+ if not button .value :
22
+ pixel .fill ((255 , 0 , 0 ))
23
+ else :
24
+ pixel .fill (0 )
You can’t perform that action at this time.
0 commit comments