forked from doniks/pycom-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathled.py
34 lines (26 loc) · 706 Bytes
/
led.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from machine import Pin
import time
# works on GPy, Fipy, Wipy
led = Pin('P9', mode=Pin.OUT) # G 16
led_off = 1
led_on = 0
led(led_off)
button = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP) # G17
while True:
if button():
# print("not pressed")
led(led_off)
else:
print("pressed")
led(led_on)
# for b in range(3):
# led.value(led_on)
# time.sleep(0.1)
# led.value(led_off)
# time.sleep(0.1)
time.sleep(0.1)
# from machine import Pin
# p_led = Pin('P9', mode=Pin.OUT)
# p_led.value(1)
# p_button = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)
# p_button.callback(Pin.IRQ_FALLING, lambda x: p_led.toggle())