pxt-microbit 5.1.32 → 5.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/block-tests.js +1 -1
- package/built/common-sim.d.ts +8 -2
- package/built/common-sim.js +21 -0
- package/built/editor.js +8 -1
- package/built/sim.d.ts +9 -3
- package/built/sim.js +30 -5
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.json +1 -1
- package/built/theme.json +1 -1
- package/built/web/react-common-authcode.css +1 -1
- package/built/web/react-common-multiplayer.css +1 -1
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-authcode.css +1 -1
- package/built/web/rtlreact-common-multiplayer.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/semantic.css +1 -1
- package/docs/projects/7-seconds.md +5 -1
- package/docs/projects/coin-flipper.md +9 -5
- package/docs/projects/compass.md +27 -23
- package/docs/projects/dice.md +9 -5
- package/docs/projects/flashing-heart.md +4 -0
- package/docs/projects/hot-potato.md +4 -0
- package/docs/projects/level.md +3 -0
- package/docs/projects/love-meter.md +13 -9
- package/docs/projects/micro-chat.md +7 -3
- package/docs/projects/name-tag.md +9 -5
- package/docs/projects/plot-acceleration.md +4 -0
- package/docs/projects/rock-paper-scissors-v2.md +5 -1
- package/docs/projects/rock-paper-scissors.md +11 -7
- package/docs/projects/smiley-buttons.md +11 -8
- package/docs/projects/stopwatch.md +5 -1
- package/docs/projects/v2-blow-away.md +28 -88
- package/docs/projects/v2-cat-napping.md +51 -72
- package/docs/projects/v2-clap-lights.md +16 -50
- package/docs/projects/v2-countdown.md +15 -47
- package/docs/projects/v2-morse-chat.md +55 -60
- package/docs/projects/v2-pet-hamster.md +16 -50
- package/docs/tours/editor-tour.md +12 -0
- package/package.json +3 -3
- package/pxtarget.json +3 -1
|
@@ -10,7 +10,7 @@ This game is inspired from the [flipping panckakes game](https://www.elecfreaks.
|
|
|
10
10
|
|
|
11
11
|
## Step 1
|
|
12
12
|
|
|
13
|
-
The player starts the timer by pressing button **A**.
|
|
13
|
+
The player starts the timer by pressing button **A**. We'll run the code run code when ``||input:button A is pressed||``.
|
|
14
14
|
|
|
15
15
|
```blocks
|
|
16
16
|
input.onButtonPressed(Button.A, function () {
|
|
@@ -97,3 +97,7 @@ input.onButtonPressed(Button.B, function () {
|
|
|
97
97
|
basic.showNumber(score)
|
|
98
98
|
})
|
|
99
99
|
```
|
|
100
|
+
|
|
101
|
+
```template
|
|
102
|
+
input.onButtonPressed(Button.A, function () {})
|
|
103
|
+
```
|
|
@@ -8,10 +8,10 @@ Let's create a coin flipping program to simulate a real coin toss. We'll use ico
|
|
|
8
8
|
|
|
9
9
|
## Step 1
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Let's start with the ``||input:on button A pressed||`` block on the Workspace. We'll put our coin flipping code in here.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
|
-
input.onButtonPressed(Button.A, ()
|
|
14
|
+
input.onButtonPressed(Button.A, function() {
|
|
15
15
|
})
|
|
16
16
|
```
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ Grab an ``||logic:if else||`` block and set it inside ``||input:on button A pres
|
|
|
22
22
|
The ``||Math:pick random true or false||`` returns a random ``true`` or ``false`` value which we use to determine a ``heads`` or ``tails`` result for a coin toss.
|
|
23
23
|
|
|
24
24
|
```blocks
|
|
25
|
-
input.onButtonPressed(Button.A, ()
|
|
25
|
+
input.onButtonPressed(Button.A, function() {
|
|
26
26
|
if (Math.randomBoolean()) {
|
|
27
27
|
} else {
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
|
|
|
34
34
|
Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``.
|
|
35
35
|
|
|
36
36
|
```blocks
|
|
37
|
-
input.onButtonPressed(Button.A, ()
|
|
37
|
+
input.onButtonPressed(Button.A, function() {
|
|
38
38
|
if (Math.randomBoolean()) {
|
|
39
39
|
basic.showIcon(IconNames.Skull)
|
|
40
40
|
} else {
|
|
@@ -52,7 +52,7 @@ Press button **A** in the simulator to try the coin toss code.
|
|
|
52
52
|
You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping.
|
|
53
53
|
|
|
54
54
|
```blocks
|
|
55
|
-
input.onButtonPressed(Button.A, ()
|
|
55
|
+
input.onButtonPressed(Button.A, function() {
|
|
56
56
|
basic.showIcon(IconNames.Diamond)
|
|
57
57
|
basic.showIcon(IconNames.SmallDiamond)
|
|
58
58
|
basic.showIcon(IconNames.Diamond)
|
|
@@ -72,3 +72,7 @@ If you have a @boardname@, connect it to USB and click ``|Download|`` to transfe
|
|
|
72
72
|
## Step 7
|
|
73
73
|
|
|
74
74
|
Press button **A** for a flip. Test your luck and guess ``heads`` or ``tails`` before the toss is over!
|
|
75
|
+
|
|
76
|
+
```template
|
|
77
|
+
input.onButtonPressed(Button.A, function() {})
|
|
78
|
+
```
|
package/docs/projects/compass.md
CHANGED
|
@@ -11,7 +11,7 @@ This tutorial will show you how to program a script that displays which directio
|
|
|
11
11
|
Store the ``||input:compass heading||`` of the @boardname@ in a variable called ``||variables:degrees||`` in the ``||basic:forever||`` loop.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
|
-
basic.forever(()
|
|
14
|
+
basic.forever(function() {
|
|
15
15
|
let degrees = input.compassHeading()
|
|
16
16
|
})
|
|
17
17
|
```
|
|
@@ -22,12 +22,12 @@ basic.forever(() => {
|
|
|
22
22
|
then the compass heading is mostly pointing toward **North**. ``||basic:Show||`` `N` on the @boardname@.
|
|
23
23
|
|
|
24
24
|
```blocks
|
|
25
|
-
basic.forever(()
|
|
26
|
-
let degrees = input.compassHeading()
|
|
25
|
+
basic.forever(function() {
|
|
26
|
+
let degrees = input.compassHeading()
|
|
27
27
|
if (degrees < 45) {
|
|
28
|
-
basic.showString("N")
|
|
28
|
+
basic.showString("N")
|
|
29
29
|
}
|
|
30
|
-
})
|
|
30
|
+
})
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Step 3
|
|
@@ -35,15 +35,15 @@ basic.forever(() => {
|
|
|
35
35
|
``||logic:If||`` ``||variables:degrees||`` is less than `135`, the @boardname@ is mostly pointing **East**. ``||basic:Show||`` `E` on the @boardname@.
|
|
36
36
|
|
|
37
37
|
```blocks
|
|
38
|
-
basic.forever(()
|
|
39
|
-
let degrees = input.compassHeading()
|
|
38
|
+
basic.forever(function() {
|
|
39
|
+
let degrees = input.compassHeading()
|
|
40
40
|
if (degrees < 45) {
|
|
41
|
-
basic.showString("N")
|
|
41
|
+
basic.showString("N")
|
|
42
42
|
}
|
|
43
43
|
else if (degrees < 135) {
|
|
44
|
-
basic.showString("E")
|
|
44
|
+
basic.showString("E")
|
|
45
45
|
}
|
|
46
|
-
})
|
|
46
|
+
})
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
## Step 4
|
|
@@ -55,18 +55,18 @@ Go to the simulator and rotate the @boardname@ logo to simulate changes in the c
|
|
|
55
55
|
``||logic:If||`` ``||variables:degrees||`` is less than `225`, the @boardname@ is mostly pointing **South**. ``||basic:Show||`` `S` on the @boardname@.
|
|
56
56
|
|
|
57
57
|
```blocks
|
|
58
|
-
basic.forever(()
|
|
59
|
-
let degrees = input.compassHeading()
|
|
58
|
+
basic.forever(function() {
|
|
59
|
+
let degrees = input.compassHeading()
|
|
60
60
|
if (degrees < 45) {
|
|
61
|
-
basic.showString("N")
|
|
61
|
+
basic.showString("N")
|
|
62
62
|
}
|
|
63
63
|
else if (degrees < 135) {
|
|
64
|
-
basic.showString("E")
|
|
64
|
+
basic.showString("E")
|
|
65
65
|
}
|
|
66
66
|
else if (degrees < 225) {
|
|
67
|
-
basic.showString("S")
|
|
67
|
+
basic.showString("S")
|
|
68
68
|
}
|
|
69
|
-
})
|
|
69
|
+
})
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
## Step 6
|
|
@@ -74,8 +74,8 @@ basic.forever(() => {
|
|
|
74
74
|
``||logic:If||`` ``||variables:degrees||`` is less than `315`, the @boardname@ is mostly pointing **West**. ``||basic:Show||`` `W` on the @boardname@.
|
|
75
75
|
|
|
76
76
|
```blocks
|
|
77
|
-
basic.forever(()
|
|
78
|
-
let degrees = input.compassHeading()
|
|
77
|
+
basic.forever(function() {
|
|
78
|
+
let degrees = input.compassHeading()
|
|
79
79
|
if (degrees < 45) {
|
|
80
80
|
basic.showString("N");
|
|
81
81
|
}
|
|
@@ -86,7 +86,7 @@ basic.forever(() => {
|
|
|
86
86
|
} else if (degrees < 315) {
|
|
87
87
|
basic.showString("W")
|
|
88
88
|
}
|
|
89
|
-
})
|
|
89
|
+
})
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
## Step 7
|
|
@@ -94,8 +94,8 @@ basic.forever(() => {
|
|
|
94
94
|
``||logic:If||`` none of these conditions returned true, then the @boardname@ must be pointing **North** again. Display `N` on the @boardname@.
|
|
95
95
|
|
|
96
96
|
```blocks
|
|
97
|
-
basic.forever(()
|
|
98
|
-
let degrees = input.compassHeading()
|
|
97
|
+
basic.forever(function() {
|
|
98
|
+
let degrees = input.compassHeading()
|
|
99
99
|
if (degrees < 45) {
|
|
100
100
|
basic.showString("N");
|
|
101
101
|
}
|
|
@@ -111,7 +111,7 @@ basic.forever(() => {
|
|
|
111
111
|
else {
|
|
112
112
|
basic.showString("N")
|
|
113
113
|
}
|
|
114
|
-
})
|
|
114
|
+
})
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
## Step 8 @unplugged
|
|
@@ -119,4 +119,8 @@ basic.forever(() => {
|
|
|
119
119
|
If you have a @boardname@, click `|Download|` and follow the screen instructions.
|
|
120
120
|
You will have to follow the screen instructions to calibrate your compass.
|
|
121
121
|
|
|
122
|
-
https://youtu.be/IL5grHtz_MU
|
|
122
|
+
https://youtu.be/IL5grHtz_MU
|
|
123
|
+
|
|
124
|
+
```template
|
|
125
|
+
basic.forever(function() {})
|
|
126
|
+
```
|
package/docs/projects/dice.md
CHANGED
|
@@ -11,10 +11,10 @@ Let's turn the @boardname@ into a dice!
|
|
|
11
11
|
|
|
12
12
|
We need 3 pieces of code: one to detect a throw (shake), another to pick a random number, and then one to show the number.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Use the ``||input:on shake||`` block you see in the editor workspace. It runs code when you shake the @boardname@.
|
|
15
15
|
|
|
16
16
|
```blocks
|
|
17
|
-
input.onGesture(Gesture.Shake, ()
|
|
17
|
+
input.onGesture(Gesture.Shake, function() {
|
|
18
18
|
|
|
19
19
|
})
|
|
20
20
|
```
|
|
@@ -24,7 +24,7 @@ input.onGesture(Gesture.Shake, () => {
|
|
|
24
24
|
Get a ``||basic:show number||`` block and place it inside the ``||input:on shake||`` block to display a number.
|
|
25
25
|
|
|
26
26
|
```blocks
|
|
27
|
-
input.onGesture(Gesture.Shake, ()
|
|
27
|
+
input.onGesture(Gesture.Shake, function() {
|
|
28
28
|
basic.showNumber(0)
|
|
29
29
|
})
|
|
30
30
|
```
|
|
@@ -34,7 +34,7 @@ input.onGesture(Gesture.Shake, () => {
|
|
|
34
34
|
Put a ``||Math:pick random||`` block in the ``||basic:show number||`` block to pick a random number.
|
|
35
35
|
|
|
36
36
|
```blocks
|
|
37
|
-
input.onGesture(Gesture.Shake, ()
|
|
37
|
+
input.onGesture(Gesture.Shake, function() {
|
|
38
38
|
basic.showNumber(randint(0, 10))
|
|
39
39
|
})
|
|
40
40
|
```
|
|
@@ -44,7 +44,7 @@ input.onGesture(Gesture.Shake, () => {
|
|
|
44
44
|
A typical dice shows values from `1` to `6`. So, in ``||Math:pick random||``, don't forget to choose the right minimum and maximum values!
|
|
45
45
|
|
|
46
46
|
```blocks
|
|
47
|
-
input.onGesture(Gesture.Shake, ()
|
|
47
|
+
input.onGesture(Gesture.Shake, function() {
|
|
48
48
|
basic.showNumber(randint(1, 6))
|
|
49
49
|
})
|
|
50
50
|
```
|
|
@@ -56,3 +56,7 @@ Use the simulator to try out your code. Does it show the number you expected?
|
|
|
56
56
|
## Step 6
|
|
57
57
|
|
|
58
58
|
If you have a @boardname@ connected, click ``|Download|`` and transfer your code to the @boardname@!
|
|
59
|
+
|
|
60
|
+
```template
|
|
61
|
+
input.onGesture(Gesture.Shake, function() {})
|
|
62
|
+
```
|
package/docs/projects/level.md
CHANGED
|
@@ -8,11 +8,11 @@ Make a love meter, how sweet! The @boardname@ is feeling the love, then sometime
|
|
|
8
8
|
|
|
9
9
|
## Step 1
|
|
10
10
|
|
|
11
|
-
Let's build a **LOVE METER** machine.
|
|
11
|
+
Let's build a **LOVE METER** machine. We'll use an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0`` from the list of pin inputs.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
|
-
input.onPinPressed(TouchPin.P0, ()
|
|
15
|
-
})
|
|
14
|
+
input.onPinPressed(TouchPin.P0, function() {
|
|
15
|
+
})
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Step 2
|
|
@@ -20,9 +20,9 @@ input.onPinPressed(TouchPin.P0, () => {
|
|
|
20
20
|
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed.
|
|
21
21
|
|
|
22
22
|
```blocks
|
|
23
|
-
input.onPinPressed(TouchPin.P0, ()
|
|
24
|
-
basic.showNumber(randint(0, 100))
|
|
25
|
-
})
|
|
23
|
+
input.onPinPressed(TouchPin.P0, function() {
|
|
24
|
+
basic.showNumber(randint(0, 100))
|
|
25
|
+
})
|
|
26
26
|
```
|
|
27
27
|
## Step 3
|
|
28
28
|
|
|
@@ -33,12 +33,16 @@ Click on pin **0** in the simulator and see which number is chosen.
|
|
|
33
33
|
Show ``"LOVE METER"`` on the screen when the @boardname@ starts.
|
|
34
34
|
|
|
35
35
|
```blocks
|
|
36
|
-
basic.showString("LOVE METER")
|
|
37
|
-
input.onPinPressed(TouchPin.P0, ()
|
|
38
|
-
basic.showNumber(randint(0, 100))
|
|
36
|
+
basic.showString("LOVE METER")
|
|
37
|
+
input.onPinPressed(TouchPin.P0, function() {
|
|
38
|
+
basic.showNumber(randint(0, 100))
|
|
39
39
|
});
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Step 5
|
|
43
43
|
|
|
44
44
|
Click ``|Download|`` to transfer your code in your @boardname@. Hold the **GND** pin with one hand and press pin **0** with the other hand to trigger this code.
|
|
45
|
+
|
|
46
|
+
```template
|
|
47
|
+
input.onPinPressed(TouchPin.P0, function() {})
|
|
48
|
+
```
|
|
@@ -21,8 +21,8 @@ Every @boardname@ nearby will receive this message.
|
|
|
21
21
|
|
|
22
22
|
```blocks
|
|
23
23
|
input.onButtonPressed(Button.A, function() {
|
|
24
|
-
radio.sendString(":)")
|
|
25
|
-
})
|
|
24
|
+
radio.sendString(":)")
|
|
25
|
+
})
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Receiving a message
|
|
@@ -51,7 +51,7 @@ Press button **A** on the simulator, you will notice that a second @boardname@ a
|
|
|
51
51
|
```blocks
|
|
52
52
|
input.onButtonPressed(Button.A, function() {
|
|
53
53
|
radio.sendString(":)");
|
|
54
|
-
})
|
|
54
|
+
})
|
|
55
55
|
radio.onReceivedString(function (receivedString) {
|
|
56
56
|
basic.showString(receivedString);
|
|
57
57
|
})
|
|
@@ -61,6 +61,10 @@ radio.onReceivedString(function (receivedString) {
|
|
|
61
61
|
|
|
62
62
|
If you have two @boardname@s, download the program to each one. Press button **A** on one and see if the other gets a message.
|
|
63
63
|
|
|
64
|
+
```template
|
|
65
|
+
//
|
|
66
|
+
```
|
|
67
|
+
|
|
64
68
|
```package
|
|
65
69
|
radio
|
|
66
70
|
```
|
|
@@ -11,9 +11,9 @@ Tell everyone who you are. Show you name on the LEDs.
|
|
|
11
11
|
Place the ``||basic:show string||`` block in the ``||basic:forever||`` block to repeat it. Change the text to your name.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
|
-
basic.forever(()
|
|
14
|
+
basic.forever(function() {
|
|
15
15
|
basic.showString("MICRO");
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Step 2
|
|
@@ -25,12 +25,16 @@ Look at the simulator and make sure it shows your name on the screen.
|
|
|
25
25
|
Place more ``||basic:show string||`` blocks to create your own story.
|
|
26
26
|
|
|
27
27
|
```blocks
|
|
28
|
-
basic.forever(()
|
|
29
|
-
basic.showString("MICRO")
|
|
30
|
-
basic.showString("<3<3<3")
|
|
28
|
+
basic.forever(function() {
|
|
29
|
+
basic.showString("MICRO")
|
|
30
|
+
basic.showString("<3<3<3")
|
|
31
31
|
})
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Step 4
|
|
35
35
|
|
|
36
36
|
If you have a @boardname@ connected, click ``|Download|`` to transfer your code and watch your name scroll!
|
|
37
|
+
|
|
38
|
+
```template
|
|
39
|
+
basic.forever(function() {})
|
|
40
|
+
```
|
|
@@ -8,7 +8,7 @@ Build a "Rock Paper Scissors" game with ADDED BONUS SOUNDS using the **micro:bit
|
|
|
8
8
|
|
|
9
9
|
## Step 1 @fullscreen
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Use the ``||input:on shake||`` block in the Workspace to run code when you shake the @boardname@.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
14
|
input.onGesture(Gesture.Shake, function () {
|
|
@@ -199,3 +199,7 @@ onto your @boardname@.
|
|
|
199
199
|
Your game is ready! Gather your friends and play Rock Paper Scissors!
|
|
200
200
|
|
|
201
201
|

|
|
202
|
+
|
|
203
|
+
```template
|
|
204
|
+
input.onGesture(Gesture.Shake, function() {})
|
|
205
|
+
```
|
|
@@ -8,10 +8,10 @@ Use the accelerometer and the screen to build a **Rock Paper Scissors** game tha
|
|
|
8
8
|
|
|
9
9
|
## Step 1 @fullscreen
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Let's use a ``||input:on shake||`` block to run code when you shake the @boardname@.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
|
-
input.onGesture(Gesture.Shake, ()
|
|
14
|
+
input.onGesture(Gesture.Shake, function() {
|
|
15
15
|
|
|
16
16
|
})
|
|
17
17
|
```
|
|
@@ -28,7 +28,7 @@ Add a ``||math:pick random||`` block to pick a random number from `1` to `3` and
|
|
|
28
28
|
|
|
29
29
|
```blocks
|
|
30
30
|
let hand = 0;
|
|
31
|
-
input.onGesture(Gesture.Shake, ()
|
|
31
|
+
input.onGesture(Gesture.Shake, function() {
|
|
32
32
|
hand = randint(1, 3)
|
|
33
33
|
})
|
|
34
34
|
```
|
|
@@ -43,7 +43,7 @@ Place an ``||logic:if||`` block under the ``||math:pick random||`` and check whe
|
|
|
43
43
|
|
|
44
44
|
```blocks
|
|
45
45
|
let hand = 0;
|
|
46
|
-
input.onGesture(Gesture.Shake, ()
|
|
46
|
+
input.onGesture(Gesture.Shake, function() {
|
|
47
47
|
hand = randint(1, 3)
|
|
48
48
|
if (hand == 1) {
|
|
49
49
|
basic.showLeds(`
|
|
@@ -71,7 +71,7 @@ Click the **(+)** button to add an ``||logic:else||`` section.
|
|
|
71
71
|
|
|
72
72
|
```blocks
|
|
73
73
|
let hand = 0;
|
|
74
|
-
input.onGesture(Gesture.Shake, ()
|
|
74
|
+
input.onGesture(Gesture.Shake, function() {
|
|
75
75
|
hand = randint(1, 3)
|
|
76
76
|
if (hand == 1) {
|
|
77
77
|
basic.showLeds(`
|
|
@@ -93,7 +93,7 @@ Add a ``||basic:show leds||`` block inside the ``||logic:else||``. Make a pictur
|
|
|
93
93
|
|
|
94
94
|
```blocks
|
|
95
95
|
let hand = 0;
|
|
96
|
-
input.onGesture(Gesture.Shake, ()
|
|
96
|
+
input.onGesture(Gesture.Shake, function() {
|
|
97
97
|
hand = randint(1, 3)
|
|
98
98
|
if (hand == 1) {
|
|
99
99
|
basic.showLeds(`
|
|
@@ -127,7 +127,7 @@ Get one more ``||basic:show leds||`` block and put it in the ``||logic:else if||
|
|
|
127
127
|
|
|
128
128
|
```blocks
|
|
129
129
|
let hand = 0;
|
|
130
|
-
input.onGesture(Gesture.Shake, ()
|
|
130
|
+
input.onGesture(Gesture.Shake, function() {
|
|
131
131
|
hand = randint(1, 3)
|
|
132
132
|
if (hand == 1) {
|
|
133
133
|
basic.showLeds(`
|
|
@@ -169,3 +169,7 @@ If you have a @boardname@, click on ``|Download|`` and follow the instructions t
|
|
|
169
169
|
onto your @boardname@. Your game is ready! Gather your friends and play Rock Paper Scissors!
|
|
170
170
|
|
|
171
171
|

|
|
172
|
+
|
|
173
|
+
```template
|
|
174
|
+
input.onGesture(Gesture.Shake, function() {})
|
|
175
|
+
```
|
|
@@ -9,11 +9,11 @@ Code the buttons on the @boardname@ to show that it's happy or sad.
|
|
|
9
9
|
|
|
10
10
|
## Step 1
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Use the ``||input:on button pressed||`` block to run code when button **A** is pressed.
|
|
13
13
|
|
|
14
14
|
```blocks
|
|
15
|
-
input.onButtonPressed(Button.A, ()
|
|
16
|
-
})
|
|
15
|
+
input.onButtonPressed(Button.A, function() {
|
|
16
|
+
})
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Step 2
|
|
@@ -21,15 +21,15 @@ input.onButtonPressed(Button.A, () => {
|
|
|
21
21
|
Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley.
|
|
22
22
|
|
|
23
23
|
```blocks
|
|
24
|
-
input.onButtonPressed(Button.A, ()
|
|
24
|
+
input.onButtonPressed(Button.A, function() {
|
|
25
25
|
basic.showLeds(`
|
|
26
26
|
# # . # #
|
|
27
27
|
# # . # #
|
|
28
28
|
. . . . .
|
|
29
29
|
# . . . #
|
|
30
30
|
. # # # .`
|
|
31
|
-
)
|
|
32
|
-
})
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Step 3
|
|
@@ -37,7 +37,7 @@ input.onButtonPressed(Button.A, () => {
|
|
|
37
37
|
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
|
|
38
38
|
|
|
39
39
|
```blocks
|
|
40
|
-
input.onButtonPressed(Button.B, ()
|
|
40
|
+
input.onButtonPressed(Button.B, function() {
|
|
41
41
|
basic.showLeds(`
|
|
42
42
|
# # . # #
|
|
43
43
|
# # . # #
|
|
@@ -53,7 +53,7 @@ input.onButtonPressed(Button.B, () => {
|
|
|
53
53
|
Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation.
|
|
54
54
|
|
|
55
55
|
```blocks
|
|
56
|
-
input.onButtonPressed(Button.AB, ()
|
|
56
|
+
input.onButtonPressed(Button.AB, function() {
|
|
57
57
|
basic.showLeds(`
|
|
58
58
|
. . . . .
|
|
59
59
|
# . # . .
|
|
@@ -79,3 +79,6 @@ If you have a @boardname@, connect it to USB and click ``|Download|`` to transfe
|
|
|
79
79
|
|
|
80
80
|
Nice! Now go and show it off to your friends!
|
|
81
81
|
|
|
82
|
+
```template
|
|
83
|
+
input.onButtonPressed(Button.A, function() {})
|
|
84
|
+
```
|
|
@@ -8,7 +8,7 @@ This project turns the @boardname@ into a simple stopwatch. Pressing **A** start
|
|
|
8
8
|
|
|
9
9
|
## Step 1
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Use an event to run code when ``||input:button A is pressed||``.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
14
|
input.onButtonPressed(Button.A, function () {
|
|
@@ -68,3 +68,7 @@ Try your program in the simulator. Press **A** to start the stopwatch and press
|
|
|
68
68
|
## Step 7
|
|
69
69
|
|
|
70
70
|
If you have a @boardname@ connected, click ``|Download|`` to transfer your code!
|
|
71
|
+
|
|
72
|
+
```template
|
|
73
|
+
input.onButtonPressed(Button.A, function () {})
|
|
74
|
+
```
|