-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
46 lines (46 loc) · 1.48 KB
/
main.ts
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
input.onButtonPressed(Button.A, function () {
if (input.temperature() >= 30) {
pins.digitalWritePin(DigitalPin.P2, 1)
} else {
pins.digitalWritePin(DigitalPin.P1, 1)
}
})
input.onButtonPressed(Button.AB, function () {
basic.showNumber(input.temperature())
})
input.onButtonPressed(Button.B, function () {
if (input.temperature() >= 30) {
pins.digitalWritePin(DigitalPin.P2, 0)
} else {
pins.digitalWritePin(DigitalPin.P1, 0)
}
})
basic.forever(function () {
while (0 == 0) {
if (input.temperature() >= 30) {
music.playMelody("C5 B A G F E D C ", 120)
pins.digitalWritePin(DigitalPin.P1, 0)
pins.digitalWritePin(DigitalPin.P2, 1)
basic.showNumber(input.temperature())
basic.showString("Fan will on")
while (input.temperature() >= 30) {
servos.P0.setAngle(180)
basic.pause(100)
servos.P0.setAngle(0)
basic.pause(100)
servos.P0.setAngle(180)
basic.pause(100)
servos.P0.setAngle(0)
basic.pause(100)
}
}
if (input.temperature() < 30) {
while (input.temperature() < 30) {
pins.digitalWritePin(DigitalPin.P2, 0)
pins.digitalWritePin(DigitalPin.P1, 1)
basic.showNumber(input.temperature())
basic.showString("Normal")
}
}
}
})