-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdom_pico.py
45 lines (38 loc) · 819 Bytes
/
dom_pico.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
35
36
37
38
39
40
41
42
43
44
from machine import Pin, Timer
from time import sleep
led = Pin(25, Pin.OUT)
btn = Pin(2, Pin.IN, Pin.PULL_UP)
led.on()
sleep(1)
led.off()
white = Pin(6, Pin.OUT)
green = Pin(7, Pin.OUT)
red = Pin(8, Pin.OUT)
breathlyser = Pin(28, Pin.IN, Pin.PULL_UP)
def assess():
print("Assess!")
total = 0
count = 0
while count < 100:
if breathlyser.value():
total += 1
sleep(0.1)
count += 1
return total > 50
while True:
led.value(btn.value())
if not btn.value():
white.on()
result = assess()
white.off()
print("Dom thinks:")
print(result)
if result:
green.on()
else:
red.on()
sleep(5)
green.off()
red.off()
while not btn.value():
pass