-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
56 lines (56 loc) · 1.32 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
input.onGesture(Gesture.Shake, function () {
basic.clearScreen()
pin = []
alarm = 1
radio.sendNumber(1)
})
input.onLogoEvent(TouchButtonEvent.Pressed, function () {
if (input.buttonIsPressed(Button.A)) {
pin.push(1)
basic.showString("1")
basic.pause(100)
basic.clearScreen()
}
if (input.buttonIsPressed(Button.B)) {
pin.push(0)
basic.showString("0")
basic.pause(100)
basic.clearScreen()
}
if (pin.length == 6) {
pinCheck = true
for (let index = 0; index <= 5; index++) {
if (code[index] != pin[index]) {
pinCheck = false
}
}
if (pinCheck == true) {
basic.showIcon(IconNames.Yes)
music.stopAllSounds()
alarm = 0
radio.sendNumber(0)
} else {
basic.showIcon(IconNames.No)
pin = []
}
}
})
let pinCheck = false
let alarm = 0
let pin: number[] = []
let code: number[] = []
radio.setGroup(42)
code = [
1,
1,
1,
0,
0,
0
]
pin = []
basic.forever(function () {
if (alarm == 1) {
music.playSoundEffect(music.createSoundEffect(WaveShape.Triangle, 5000, 228, 255, 255, 2000, SoundExpressionEffect.Vibrato, InterpolationCurve.Logarithmic), SoundExpressionPlayMode.InBackground)
}
})