-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
29 lines (29 loc) · 713 Bytes
/
main.ts
File metadata and controls
29 lines (29 loc) · 713 Bytes
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
let reading = 0
let degrees = 0
input.onButtonPressed(Button.A, function () {
basic.showNumber(input.temperature())
})
input.onButtonPressed(Button.AB, function () {
reading = input.lightLevel()
led.plotBarGraph(
reading,
255
)
if (input.buttonIsPressed(Button.A)) {
basic.showNumber(reading)
}
})
input.onButtonPressed(Button.B, function () {
degrees = input.compassHeading()
if (degrees < 45) {
basic.showString("N")
} else if (degrees < 135) {
basic.showString("E")
} else if (degrees < 225) {
basic.showString("S")
} else if (degrees < 315) {
basic.showString("W")
} else {
basic.showString("N")
}
})