-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasomecode
More file actions
105 lines (92 loc) · 2.21 KB
/
asomecode
File metadata and controls
105 lines (92 loc) · 2.21 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from asomeneopixel import NEO
import random as rd
import time
import dht11
import i2c_lcd
import music
lcd = i2c_lcd.create(1,10)
dh = dht11.create(5)
NEO.ready(4,8)
light = AnalogPin(1)
distance = AnalogPin(2)
music.open(12)
myservo = ServoPin(6)
motora = ServoPin(19)
motorb = ServoPin(20)
air = AnalogPin(14)
def write_rainb():
for j in range(30):
NEO.color((j+7)%8,0,0,0)
NEO.color((j+6)%8,100,0,255)
NEO.color((j+5)%8,0,20,255)
NEO.color((j+4)%8,0,0,255)
NEO.color((j+3)%8,0,255,0)
NEO.color((j+2)%8,255,255,0)
NEO.color((j+1)%8,255,50,0)
NEO.color(j%8,255,0,0)
NEO.write()
time.sleep(0.1)
def write_on():
for i in range(8):
NEO.color(i,100,100,100)
NEO.write()
def write_off():
NEO.clear()
NEO.write()
def song():
music.tone(262)
delay(0.2)
music.tone(262)
delay(0.2)
music.tone(294)
delay(0.2)
music.tone(330)
delay(0.2)
music.tone(330)
delay(0.2)
music.tone(294)
delay(0.2)
music.tone(262)
delay(0.2)
music.tone(262)
delay(0.2)
music.mute()
while True:
lightV = light.read()
distanceV = distance.read()
dh.measure()
humidity = dh.humidity()
temperature = dh.temperature()
human_temp = dh.compute_heat_index(temperature,humidity)
di = int(0.81 * temperature + 0.01 * humidity * (0.99 * temperature - 14.3) + 46.3)
airV = air.read()
#불쾌지수
print(f'{temperature}C, {humidity}%, body:{human_temp}, di:{di}')
print(f'air:{airV}')
if di > 75 or airV > 400:
myservo.angle(0)
lcd.clear()
lcd.move(0,0)
lcd.write('window')
lcd.move(0,1)
lcd.write('open')
motora.duty(0)
motorb.duty(100)
else:
myservo.angle(90)
motora.duty(0)
motorb.duty(0)
lcd.clear()
lcd.move(0,0)
lcd.write(f'{humidity}C, {temperature}%')
lcd.move(0,1)
lcd.write(f'{human_temp}, {di}')
if lightV > 4000:
write_rainb()
song()
elif lightV > 2000 and distanceV < 60:
write_on()
music.mute()
else:
write_off()
music.mute()