Skip to content

Commit d3c3190

Browse files
committed
removed functions from callbacks test and used pico_led instead of LED to remove need for external components when running examples.
1 parent c121d13 commit d3c3190

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

docs/examples/touch_sensor.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
from picozero import TouchSensor, LED
1+
from picozero import TouchSensor, pico_led
22
from time import sleep
33

44
# Capacitive touch sensor output connected to pin 2
55
touch = TouchSensor(2)
66

7-
# Built-in LED
8-
led = LED(25)
9-
107
while 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)
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
from picozero import TouchSensor, LED
1+
from picozero import TouchSensor, pico_led
22
from time import sleep
33

44
# Capacitive touch sensor output connected to pin 2
55
touch = 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
2412
try:
2513
while True:
2614
sleep(1)
2715
except KeyboardInterrupt:
28-
led.off() # Turn LED off when exiting
16+
pico_led.off() # Turn LED off when exiting

0 commit comments

Comments
 (0)