-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
83 lines (83 loc) · 1.75 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
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
radio.onReceivedNumber(function (receivedNumber) {
if (sent == 0) {
radio.sendNumber(v)
basic.showIcon(IconNames.SmallDiamond)
sent = 1
basic.pause(500)
}
if (v == receivedNumber) {
basic.showLeds(`
. . . . .
# # # # #
. . . . .
# # # # #
. . . . .
`)
} else {
if (v == 1 && receivedNumber == 2 || (v == 2 && receivedNumber == 3 || v == 3 && receivedNumber == 1)) {
basic.showIcon(IconNames.Yes)
} else {
basic.showIcon(IconNames.No)
}
}
basic.pause(5000)
sent = 0
present(v)
})
function present (num: number) {
if (num == 1) {
basic.showLeds(`
# # # # .
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else {
if (num == 2) {
basic.showLeds(`
. . . . .
. # # # .
# # # # #
# # # # #
. # # # .
`)
} else {
basic.showLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
. . # . .
`)
}
}
}
input.onButtonPressed(Button.A, function () {
v += 1
if (v == 4) {
v = 1
}
present(v)
basic.pause(100)
})
input.onButtonPressed(Button.AB, function () {
radio.sendNumber(v)
sent = 1
basic.showIcon(IconNames.SmallDiamond)
basic.pause(500)
})
input.onButtonPressed(Button.B, function () {
v += -1
if (v == 0) {
v = 3
}
present(v)
basic.pause(100)
})
let sent = 0
let v = 0
radio.setGroup(1)
v = 1
sent = 0
present(v)