We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 25237c5 commit c696cd5Copy full SHA for c696cd5
micropython/examples/tiny2040/button_test.py
@@ -0,0 +1,28 @@
1
+# Simple demo of how to use the RGB LED and read the button on Tiny 2040.
2
+
3
+from pimoroni import Button, RGBLED
4
+import time
5
6
+led = RGBLED(18, 19, 20)
7
+button_boot = Button(23)
8
9
+# start with the LED off
10
+led.set_rgb(0, 0, 0)
11
12
+# flash the LED red, green and blue
13
+led.set_rgb(255, 0, 0)
14
+time.sleep(0.5)
15
+led.set_rgb(0, 255, 0)
16
17
+led.set_rgb(0, 0, 255)
18
19
20
+print("Press the button!")
21
22
+while True:
23
+ # flash the LED white when the button is pressed
24
+ if button_boot.read():
25
+ print("Button pressed!")
26
+ led.set_rgb(255, 255, 255)
27
+ time.sleep(0.5)
28
+ led.set_rgb(0, 0, 0)
0 commit comments