-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (31 loc) · 1.05 KB
/
main.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
# setup.py : setup()
# temhum.py : check_temNhum()
# distance.py : inout_setup(), measure_distance(), stop()
# led.py : state(),
import temhum, distance, setup, led, send
import time
TRIG, ECHO, DHT_SENSOR, DHT_PIN, Gled, Rled = setup.setup()
umbrella_present = False
def main():
#핀모드 설정
distance.inout_setup(TRIG, ECHO)
try:
while True:
# 온습도 측정
humidity, temperature = temhum.check_temNhum(DHT_SENSOR, DHT_PIN)
# 거리 측정
how_far = distance.measure_distance(TRIG, ECHO)
if how_far <= 10:
umbrella_present = True
else:
umbrella_present = False
# led 출력
led.state(Gled, Rled, how_far)
# 서버로 데이터 보내기
send.send_data(temperature, humidity, umbrella_present)
print('')
# 1초 쉬기
time.sleep(1)
except KeyboardInterrupt:
distance.stop()
main()