File tree Expand file tree Collapse file tree 2 files changed +7
-22
lines changed Expand file tree Collapse file tree 2 files changed +7
-22
lines changed Original file line number Diff line number Diff line change 1- from picozero import TouchSensor , LED
1+ from picozero import TouchSensor , pico_led
22from time import sleep
33
44# Capacitive touch sensor output connected to pin 2
55touch = TouchSensor (2 )
66
7- # Built-in LED
8- led = LED (25 )
9-
107while True :
118 if touch .is_touched :
12- led .on ()
9+ pico_led .on ()
1310 else :
14- led .off ()
11+ pico_led .off ()
1512 sleep (0.1 )
Original file line number Diff line number Diff line change 1- from picozero import TouchSensor , LED
1+ from picozero import TouchSensor , pico_led
22from time import sleep
33
44# Capacitive touch sensor output connected to pin 2
55touch = TouchSensor (2 )
66
7- # Built-in LED
8- led = LED (25 )
9-
10-
11- def touched ():
12- led .on ()
13-
14-
15- def released ():
16- led .off ()
17-
18-
197# Set up event callbacks
20- touch .when_touched = touched
21- touch .when_touch_ends = released
8+ touch .when_touched = pico_led . on
9+ touch .when_touch_ends = pico_led . off
2210
2311# Keep the program running
2412try :
2513 while True :
2614 sleep (1 )
2715except KeyboardInterrupt :
28- led .off () # Turn LED off when exiting
16+ pico_led .off () # Turn LED off when exiting
You can’t perform that action at this time.
0 commit comments