-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrobit_Radio_Send.js
59 lines (59 loc) · 1.53 KB
/
Microbit_Radio_Send.js
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
/**********************************************************************************************
* Program for Microbit to Send information to another Microbit to communicate with Arduino *
***********************************************************************************************/
input.onGesture(Gesture.Shake, function () {
// tell other microbit to send "G" for go
radio.sendString("G")
basic.showLeds(`
. . . . .
. . . . #
. . . # .
# . # . .
. # . . .
`)
basic.pause(200)
basic.clearScreen()
})
// if A is pressed (left button)
input.onButtonPressed(Button.B, function () {
// tell other microbit to send "R" for right
radio.sendString("R")
basic.showLeds(`
. . # . .
. . . # .
# # # # #
. . . # .
. . # . .
`)
basic.pause(200)
basic.clearScreen()
})
// when A and B are pressed...
input.onButtonPressed(Button.AB, function () {
// tell other microbit to send "G" for stop
radio.sendString("S")
basic.showLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`)
basic.pause(200)
basic.clearScreen()
})
// if B is pressed (right button)
input.onButtonPressed(Button.A, function () {
// tell other microbit to send "L" for left
radio.sendString("L")
basic.showLeds(`
. . # . .
. # . . .
# # # # #
. # . . .
. . # . .
`)
basic.pause(200)
basic.clearScreen()
})
radio.setGroup(1)