-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.ts
28 lines (28 loc) · 787 Bytes
/
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
let y = 0
let x = 0
let angle = 0
radio.setGroup(1)
radio.setTransmitPower(7)
basic.showIcon(IconNames.Heart)
basic.forever(function () {
if (GHBit.Button(GHBit.enButton.B1, GHBit.enButtonState.Press)) {
angle = -1
} else if (GHBit.Button(GHBit.enButton.B4, GHBit.enButtonState.Press)) {
angle = 1
} else {
angle = 0
}
radio.sendValue("a", angle)
if (GHBit.Button(GHBit.enButton.B2, GHBit.enButtonState.Press)) {
x = 0
y = 512
} else if (GHBit.Button(GHBit.enButton.B3, GHBit.enButtonState.Press)) {
x = 0
y = -512
} else {
x = 0 - pins.analogReadPin(AnalogPin.P2) + 512
y = 0 - pins.analogReadPin(AnalogPin.P1) + 512
}
radio.sendValue("x", x)
radio.sendValue("y", y)
})