-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
72 lines (72 loc) · 1.73 KB
/
main.ts
File metadata and controls
72 lines (72 loc) · 1.73 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
input.onButtonPressed(Button.A, function () {
running = false
})
input.onButtonPressed(Button.B, function () {
running = true
})
let running = false
let top_angle = 70
let bottom_angle = 120
let fan_time = 1
let fan_power = 150
basic.forever(function () {
if (running) {
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . . . .
. . # . .
. # . # .
. . # . .
. . . . .
`)
basic.showLeds(`
. . # . .
. # . # .
# . . . #
. # . # .
. . # . .
`)
basic.showLeds(`
. # . # .
# . . . #
. . . . .
# . . . #
. # . # .
`)
} else {
basic.showString("PRESS")
basic.showArrow(ArrowNames.East)
}
})
basic.forever(function () {
if (running) {
pins.digitalWritePin(DigitalPin.P1, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P1, 0)
basic.pause(500)
} else {
pins.digitalWritePin(DigitalPin.P1, 1)
basic.pause(50)
pins.digitalWritePin(DigitalPin.P1, 0)
basic.pause(1000)
}
})
basic.forever(function () {
if (running) {
pins.servoWritePin(AnalogPin.P2, bottom_angle)
pins.analogWritePin(AnalogPin.P0, 0)
basic.pause(1000)
pins.servoWritePin(AnalogPin.P2, top_angle)
pins.analogWritePin(AnalogPin.P0, fan_power)
basic.pause(fan_time * 1000)
} else {
pins.servoWritePin(AnalogPin.P2, top_angle)
pins.analogWritePin(AnalogPin.P0, 0)
}
})