pxt-microbit 6.1.4 → 6.1.6

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.
@@ -4,172 +4,227 @@
4
4
 
5
5
  ![Cartoon of the Rock Paper Scissors game](/static/mb/projects/a4-motion.png)
6
6
 
7
- Use the accelerometer and the screen to build a **Rock Paper Scissors** game that you can play with your friends!
7
+ Turn your micro:bit into a **Rock Paper Scissors** game that you can play with your friends!
8
8
 
9
- ## {Step 1 @fullscreen}
9
+ ## {Step 1}
10
10
 
11
- Let's use a ``||input:on shake||`` block to run code when you shake the @boardname@.
11
+ First we need to make a variable to keep track of whether we have a Rock, Paper or Scissors in our hand. A variable is a container for storing values. Click on the ``||variables:Variables||`` category in the Toolbox. Click on the **Make a Variable** button. Give your new variable the name "hand" and click Ok.
12
+
13
+ ![A animation that shows how to create a variable](/static/mb/projects/rock-paper-scissors/newvar.gif)
14
+
15
+ ## {Step 2}
16
+
17
+ Click on the ``||variables:Variables||`` category in the Toolbox again. You'll notice that there are some new blocks that have appeared. Drag a ``||variables:set hand||`` block into the ``||input:on shake||`` block. We'll start our Rock Paper Scissors game when we shake 👋 our micro:bit.
12
18
 
13
19
  ```blocks
20
+ let hand = 0;
14
21
  input.onGesture(Gesture.Shake, function() {
15
-
22
+ hand = 0
16
23
  })
17
24
  ```
18
25
 
19
- ## {Step 2 @fullscreen}
26
+ ## {Step 3}
20
27
 
21
- Add a ``hand`` variable and place the ``||variables:set hand to||`` block in the shake event.
28
+ Click on the ``||math:Math||`` category in the Toolbox. Drag a ``||math:pick random||`` block and drop it into the ``||variables:set hand||`` block replacing the number 0. Now when we shake our micro:bit, the variable hand will contain a random number between 1 and 3.
22
29
 
23
- ![A animation that shows how to create a variable](/static/mb/projects/rock-paper-scissors/newvar.gif)
30
+ ```blocks
31
+ let hand = 0;
32
+ input.onGesture(Gesture.Shake, function() {
33
+ hand = randint(1, 3)
34
+ })
35
+ ```
24
36
 
25
- ## {Step 3 @fullscreen}
37
+ ## {Step 4}
26
38
 
27
- Add a ``||math:pick random||`` block to pick a random number from `1` to `3` and store it in the variable named ``hand``.
39
+ Click on the ``||logic:Logic||`` category in the Toolbox. Drag the ``||logic:if true then else||`` block out to the workspace and drop it into the ``||input:on shake||`` block under the ``||variables:set hand||`` block.
28
40
 
29
41
  ```blocks
30
42
  let hand = 0;
31
43
  input.onGesture(Gesture.Shake, function() {
32
44
  hand = randint(1, 3)
45
+ if (true) {
46
+
47
+ } else {
48
+
49
+ }
33
50
  })
34
51
  ```
35
52
 
36
- In a later step, each of the possible numbers (`1`, `2`, or `3`) is matched to its own picture. The picture is shown on the LEDs when its matching number is picked.
53
+ ## {Step 5}
37
54
 
38
- ## {Step 4 @fullscreen}
55
+ From the ``||logic:Logic||`` category, drag a ``||logic:0 = 0||`` comparison block and drop it into the ``||logic:if true then else||`` block replacing **true**.
39
56
 
40
- Place an ``||logic:if||`` block under the ``||math:pick random||`` and check whether ``hand`` is equal to ``1``. Add a ``||basic:show leds||`` block that shows a picture of a piece of paper. The number `1` will mean paper.
57
+ ```blocks
58
+ let hand = 0;
59
+ input.onGesture(Gesture.Shake, function() {
60
+ hand = randint(1, 3)
61
+ if (0 == 0) {
62
+
63
+ } else {
64
+
65
+ }
66
+ })
67
+ ```
41
68
 
42
- ![How to drag an if statement](/static/mb/projects/rock-paper-scissors/if.gif)
69
+ ## {Step 6}
70
+
71
+ Click on the ``||variables:Variables||`` category in the Toolbox. Drag a ``||variables:hand||`` block out and drop it into the ``||logic:0 = 0||`` comparison block replacing the first **0**. Click on the second 0 in the comparison block and change to **1**.
43
72
 
44
73
  ```blocks
45
74
  let hand = 0;
46
75
  input.onGesture(Gesture.Shake, function() {
47
76
  hand = randint(1, 3)
48
77
  if (hand == 1) {
49
- basic.showLeds(`
50
- # # # # #
51
- # . . . #
52
- # . . . #
53
- # . . . #
54
- # # # # #
55
- `)
78
+
79
+ } else {
80
+
56
81
  }
57
82
  })
58
83
  ```
59
84
 
60
- ## {Step 5 @fullscreen}
85
+ ## {Step 7}
61
86
 
62
- Click on the **SHAKE** button in the simulator. If you try enough times, you should see a picture of paper on the screen.
87
+ Click on the ``||basic:Basic||`` category in the Toolbox. Drag a ``||basic:show icon||`` block out and drop it under ``||logic:if hand = 1 then||``. In the ``||basic:show icon||`` block, click on the Heart icon and instead select the small square icon to represent a 💎 Rock.
63
88
 
64
- ![Shaking a @boardname@ simulator](/static/mb/projects/rock-paper-scissors/rpsshake.gif)
65
-
66
- ## {Step 6 @fullscreen}
89
+ ```blocks
90
+ let hand = 0;
91
+ input.onGesture(Gesture.Shake, function() {
92
+ hand = randint(1, 3)
93
+ if (hand == 1) {
94
+ basic.showIcon(IconNames.SmallSquare)
95
+ } else {
96
+
97
+ }
98
+ })
99
+ ```
67
100
 
68
- Click the **(+)** button to add an ``||logic:else||`` section.
101
+ ## {Step 8}
69
102
 
70
- ![Adding an else clause](/static/mb/projects/rock-paper-scissors/ifelse.gif)
103
+ At the bottom of the ``||logic:if then else||`` block, click on the plus **'+'** sign. This will expand the code to include an ``||logic:else if||`` clause.
71
104
 
72
105
  ```blocks
73
106
  let hand = 0;
74
107
  input.onGesture(Gesture.Shake, function() {
75
108
  hand = randint(1, 3)
76
109
  if (hand == 1) {
77
- basic.showLeds(`
78
- # # # # #
79
- # . . . #
80
- # . . . #
81
- # . . . #
82
- # # # # #
83
- `)
110
+ basic.showIcon(IconNames.SmallSquare)
111
+ } else if (false) {
112
+
84
113
  } else {
114
+
115
+ }
116
+ })
117
+ ```
118
+
119
+ ## {Step 9}
120
+
121
+ From the ``||logic:Logic||`` category, drag a ``||logic:0 = 0||`` comparison block and drop it into the open space next to the ``||logic:else if||`` clause.
85
122
 
123
+ ```blocks
124
+ let hand = 0;
125
+ input.onGesture(Gesture.Shake, function() {
126
+ hand = randint(1, 3)
127
+ if (hand == 1) {
128
+ basic.showIcon(IconNames.SmallSquare)
129
+ } else if (0 == 0) {
130
+
131
+ } else {
132
+
86
133
  }
87
134
  })
88
135
  ```
89
136
 
90
- ## {Step 7 @fullscreen}
137
+ ## {Step 10}
91
138
 
92
- Add a ``||basic:show leds||`` block inside the ``||logic:else||``. Make a picture of a scissors in the LEDs.
139
+ From the ``||variables:Variables||`` category, drag a ``||variables:hand||`` block and drop it into the ``||logic:0 = 0||`` comparison block replacing the first **0**. Click on the second 0 in the comparison block and change to **2**.
93
140
 
94
141
  ```blocks
95
142
  let hand = 0;
96
143
  input.onGesture(Gesture.Shake, function() {
97
144
  hand = randint(1, 3)
98
145
  if (hand == 1) {
99
- basic.showLeds(`
100
- # # # # #
101
- # . . . #
102
- # . . . #
103
- # . . . #
104
- # # # # #
105
- `)
146
+ basic.showIcon(IconNames.SmallSquare)
147
+ } else if (hand == 2) {
148
+
106
149
  } else {
107
- basic.showLeds(`
108
- # # . . #
109
- # # . # .
110
- . . # . .
111
- # # . # .
112
- # # . . #
113
- `)
150
+
114
151
  }
115
152
  })
116
153
  ```
117
154
 
118
- ## {Step 8 @fullscreen}
155
+ ## {Step 11}
119
156
 
120
- Click the ``+`` button again to add an ``||logic:else if||`` section. Now, add a conditional block for ``||logic:hand = 2||`` to the condition in ``||logic:else if||``. Since ``hand`` can only be `1`, `2`, or `3`, your code is covering all possible cases!
157
+ From the ``||basic:Basic||`` category, drag a ``||basic:show icon||`` block out and drop it under ``||logic:else if hand = 2 then||``. In the ``||basic:show icon||`` block, click on the Heart icon and instead select the large square icon to represent 📃 Paper.
121
158
 
122
- ![Adding an else if clause](/static/mb/projects/rock-paper-scissors/ifelseif.gif)
159
+ ```blocks
160
+ let hand = 0;
161
+ input.onGesture(Gesture.Shake, function() {
162
+ hand = randint(1, 3)
163
+ if (hand == 1) {
164
+ basic.showIcon(IconNames.SmallSquare)
165
+ } else if (hand == 2) {
166
+ basic.showIcon(IconNames.Square)
167
+ } else {
168
+
169
+ }
170
+ })
171
+ ```
123
172
 
124
- ## {Step 9 @fullscreen}
173
+ ## {Step 12}
125
174
 
126
- Get one more ``||basic:show leds||`` block and put it in the ``||logic:else if||``. Make a picture of a rock in the LEDs.
175
+ Now let's deal with the last condition - if our hand variable isn't holding a 1 (Rock) or a 2 (Paper), then it must be 3 (✀ Scissors)! From the ``||basic:Basic||`` category, drag another ``||basic:show icon||`` block out and drop it into the last opening under the ``||logic:else||``. In the ``||basic:show icon||`` block, click on the Heart icon and select the Scissors icon.
127
176
 
128
177
  ```blocks
129
178
  let hand = 0;
130
179
  input.onGesture(Gesture.Shake, function() {
131
180
  hand = randint(1, 3)
132
181
  if (hand == 1) {
133
- basic.showLeds(`
134
- # # # # #
135
- # . . . #
136
- # . . . #
137
- # . . . #
138
- # # # # #
139
- `)
182
+ basic.showIcon(IconNames.SmallSquare)
140
183
  } else if (hand == 2) {
141
- basic.showLeds(`
142
- . . . . .
143
- . # # # .
144
- . # # # .
145
- . # # # .
146
- . . . . .
147
- `)
184
+ basic.showIcon(IconNames.Square)
148
185
  } else {
149
- basic.showLeds(`
150
- # # . . #
151
- # # . # .
152
- . . # . .
153
- # # . # .
154
- # # . . #
155
- `)
186
+ basic.showIcon(IconNames.Scissors)
156
187
  }
157
188
  })
158
189
  ```
159
190
 
160
- ## {Step 10 @fullscreen}
191
+ ## {Step 13}
161
192
 
162
- Click on the **SHAKE** button in the simulator and check to see that each image is showing up.
193
+ Let's test your code! Press the white **SHAKE** button on the micro:bit on-screen simulator, or move your cursor quickly back and forth over the simulator. Do you see the icons for rock, paper and scissors randomly appear? ⭐ Great job! ⭐
163
194
 
164
195
  ![Shaking a @boardname@ simulator](/static/mb/projects/rock-paper-scissors/rpssim3.gif)
165
196
 
166
- ## {Step 11 @fullscreen}
197
+ ## {Step 14}
167
198
 
168
- If you have a @boardname@, click on ``|Download|`` and follow the instructions to get the code
169
- onto your @boardname@. Your game is ready! Gather your friends and play Rock Paper Scissors!
199
+ If you have a @boardname@ device, connect it to your computer and click the ``|Download|`` button. Follow the instructions to transfer your code onto the @boardname@. Once your code has been downloaded, attach your micro:bit to a battery pack and challenge another micro:bit or a human to a game of Rock, Paper, Scissors!
170
200
 
171
201
  ![A @boardname@ in a hand](/static/mb/projects/rock-paper-scissors/hand.jpg)
172
202
 
203
+ ## {Step 15}
204
+
205
+ Go further - Try adding 🎵 Music 🎵 blocks to your Rock Paper Scissors game for different sound effects. Note that some Music blocks may require a micro:bit v2 device to play.
206
+
207
+ ```blocks
208
+ let hand = 0
209
+ input.onGesture(Gesture.Shake, function () {
210
+ hand = randint(1, 3)
211
+ if (hand == 1) {
212
+ basic.showIcon(IconNames.SmallSquare)
213
+ music.play(music.builtinPlayableSoundEffect(soundExpression.giggle), music.PlaybackMode.UntilDone)
214
+ } else if (hand == 2) {
215
+ basic.showIcon(IconNames.Square)
216
+ music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone)
217
+ } else {
218
+ basic.showIcon(IconNames.Scissors)
219
+ music.play(music.createSoundExpression(WaveShape.Square, 1600, 1, 255, 0, 300, SoundExpressionEffect.None, InterpolationCurve.Curve), music.PlaybackMode.UntilDone)
220
+ }
221
+ })
222
+ ```
223
+
224
+ ```blockconfig.global
225
+ randint(1, 3)
226
+ ```
227
+
173
228
  ```template
174
229
  input.onGesture(Gesture.Shake, function() {})
175
230
  ```
@@ -1,83 +1,61 @@
1
1
  # Smiley Buttons
2
2
 
3
- ## {Introduction @unplugged}
3
+ ## Code a micro:bit emoji! @unplugged
4
4
 
5
- Code the buttons on the @boardname@ to show that it's happy or sad.
6
- (Want to learn how the buttons works? [Watch this video](https://youtu.be/t_Qujjd_38o)).
5
+ Program the buttons on the @boardname@ to show a happy 😀 or sad face 🙁
7
6
 
8
7
  ![Pressing the A and B buttons](/static/mb/projects/smiley-buttons/sim.gif)
9
8
 
10
9
  ## {Step 1}
11
10
 
12
- Use the ``||input:on button pressed||`` block to run code when button **A** is pressed.
11
+ Let's show a happy face when we press button **A**.
12
+ Click on the ``||basic:Basic||`` category in the Toolbox. Drag a ``||basic:show icon||`` block into the ``||input:on button A pressed||`` block.
13
+ In the ``||basic:show icon||`` block, click on the Heart icon to open the menu. Select a Happy Face icon.
13
14
 
14
15
  ```blocks
15
16
  input.onButtonPressed(Button.A, function() {
17
+ basic.showIcon(IconNames.Happy)
16
18
  })
17
19
  ```
18
20
 
19
21
  ## {Step 2}
20
22
 
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
-
23
- ```blocks
24
- input.onButtonPressed(Button.A, function() {
25
- basic.showLeds(`
26
- # # . # #
27
- # # . # #
28
- . . . . .
29
- # . . . #
30
- . # # # .`
31
- )
32
- })
33
- ```
23
+ In the @boardname@ simulator on the screen, press the **A** button. Do you see a happy face? ⭐ Great job! ⭐
34
24
 
35
25
  ## {Step 3}
36
26
 
37
- Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
27
+ Now let's show a sad face when we press button **B**.
28
+ Click on the ``||input:Input||`` category in the Toolbox.
29
+ Drag another ``||input:on button A pressed||`` block onto the coding workspace (you can place this anywhere).
30
+ Click on the **A** button drop-down menu, and select **B**.
38
31
 
39
32
  ```blocks
40
- input.onButtonPressed(Button.B, function() {
41
- basic.showLeds(`
42
- # # . # #
43
- # # . # #
44
- . . . . .
45
- . # # # .
46
- # . . . #`
47
- );
48
- });
33
+ input.onButtonPressed(Button.B, function() {})
49
34
  ```
50
35
 
51
36
  ## {Step 4}
52
37
 
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.
38
+ From the ``||basic:Basic||`` category, drag another ``||basic:show icon||`` block into the ``||input:on button B pressed||`` block.
39
+ In this ``||basic:show icon||`` block, click on the Heart icon to open the menu.
40
+ Select a Sad Face icon.
54
41
 
55
42
  ```blocks
56
- input.onButtonPressed(Button.AB, function() {
57
- basic.showLeds(`
58
- . . . . .
59
- # . # . .
60
- . . . . .
61
- # . . . #
62
- . # # # .
63
- `)
64
- basic.showLeds(`
65
- . . . . .
66
- . . # . #
67
- . . . . .
68
- # . . . #
69
- . # # # .
70
- `)
43
+ input.onButtonPressed(Button.B, function() {
44
+ basic.showIcon(IconNames.Sad)
71
45
  })
72
46
  ```
73
-
74
47
  ## {Step 5}
75
48
 
76
- If you have a @boardname@, connect it to USB and click ``|Download|`` to transfer your code. Press button **A** on your @boardname@. Try button **B** and then **A** and **B** together.
49
+ In the @boardname@ simulator on the screen, press the **B** button. Do you see a sad face? Great job!
77
50
 
78
51
  ## {Step 6}
79
52
 
80
- Nice! Now go and show it off to your friends!
53
+ If you have a @boardname@ device, connect it to your computer and click the ``|Download|`` button. Follow the instructions to transfer your code onto the @boardname@. Try pressing the **A** and **B** buttons on the micro:bit to see your happy 😀 and sad 🙁 emojis!
54
+
55
+ ## {Step 7}
56
+
57
+ Go further - try adding a secret emoji that appears when **A** and **B** buttons are pressed together!
58
+ Learn more about how the @boardname@ buttons work by watching [this video](https://youtu.be/t_Qujjd_38o).
81
59
 
82
60
  ```template
83
61
  input.onButtonPressed(Button.A, function() {})
@@ -2,18 +2,15 @@
2
2
 
3
3
  ### @explicitHints true
4
4
 
5
- ## Introduction @unplugged
5
+ ## {Introduction @unplugged}
6
6
 
7
- Let's turn the @boardname@ into a dice!
8
- (Want to learn how the accelerometer works? [Watch this video](https://youtu.be/byngcwjO51U)).
9
-
10
- 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.
7
+ Let's create some digital 🎲 dice 🎲 with our micro:bit!
11
8
 
12
9
  ![A @boardname@ dice](/static/mb/projects/dice.png)
13
10
 
14
- ## Step 1
11
+ ## {Step 1}
15
12
 
16
- Add an event to run code when a ``||input:shake gesture||`` is detected.
13
+ We'll "roll" our dice when we shake the micro:bit. Add an ``||input:on gesture shake||`` function. Type the code below, or drag a code snippet from the ``||input:Input||`` Toolbox category.
17
14
 
18
15
  ```spy
19
16
  input.onGesture(Gesture.Shake, function() {
@@ -21,9 +18,9 @@ input.onGesture(Gesture.Shake, function() {
21
18
  })
22
19
  ```
23
20
 
24
- ## Step 2
21
+ ## {Step 2}
25
22
 
26
- Put code in the event to ``||basic:show a number||`` when ``||input:on shake||`` happens.
23
+ Write some code to show a number in the ``||input:on shake||`` function, using the basic ``||basic:show number||`` function.
27
24
 
28
25
  ```spy
29
26
  input.onGesture(Gesture.Shake, function() {
@@ -31,9 +28,9 @@ input.onGesture(Gesture.Shake, function() {
31
28
  })
32
29
  ```
33
30
 
34
- ## Step 3
31
+ ## {Step 3}
35
32
 
36
- Pick a ``||math:pick a random||`` number and ``||basic:show||`` it on the screen.
33
+ Instead of showing 0, use the ``||math:randint||`` function to show a random number between a minimum and maximum value.
37
34
 
38
35
  ```spy
39
36
  input.onGesture(Gesture.Shake, function() {
@@ -41,9 +38,9 @@ input.onGesture(Gesture.Shake, function() {
41
38
  })
42
39
  ```
43
40
 
44
- ## Step 4
41
+ ## {Step 4}
45
42
 
46
- A typical dice shows values from `1` to `6`. Change the minimum and maximum values in ``||math:pick random||`` to ``1`` and ``6``!
43
+ A typical dice shows values from 1 to 6 dots. So, in the ``||math:randint||`` function, change the minimum value to **1** and the maximum value to **6**.
47
44
 
48
45
  ```spy
49
46
  input.onGesture(Gesture.Shake, function() {
@@ -51,10 +48,13 @@ input.onGesture(Gesture.Shake, function() {
51
48
  })
52
49
  ```
53
50
 
54
- ## Step 5
51
+ ## {Step 5}
52
+
53
+ Press the white **SHAKE** button on the micro:bit simulator. Do you see random numbers between 1 and 6 appear? ⭐ Great job! ⭐
55
54
 
56
- Use the simulator to try out your code. Does it show the number you expected?
55
+ ## {Step 6}
57
56
 
58
- ## Step 6
57
+ If you have a @boardname@ device, connect it to your computer and click the ``|Download|`` button. Follow the instructions to transfer your code onto the @boardname@. Once your code has been downloaded, attach your micro:bit to a battery pack and use it as digital 🎲 dice for your next boardgame!
59
58
 
60
- If you have a @boardname@ connected, click ``|Download|`` and transfer your code to the @boardname@!
59
+ ## {Step 7}
60
+ Go further - Try adding some Music blocks to make a sound when you shake your dice, or use the micro:bit LED lights to show number values. Want to learn how the micro:bit motion detector or accelerometer works? [Watch this video](https://youtu.be/byngcwjO51U).
@@ -2,24 +2,23 @@
2
2
 
3
3
  ### @explicitHints true
4
4
 
5
- ## Introduction @unplugged
5
+ ## Code a Flashing Heart @unplugged
6
6
 
7
- Learn how to use the LEDs and make a flashing heart!
8
- (Want to learn how lights work? [Watch this video](https://youtu.be/qqBmvHD5bCw)).
7
+ Code the lights on the micro:bit into a flashing heart animation! 💖
9
8
 
10
9
  ![Heart shape in the LEDs](/static/mb/projects/flashing-heart/sim.gif)
11
10
 
12
- ## Step 1 @fullscreen
11
+ ## {Step 1 @fullscreen}
13
12
 
14
- Make the screen ``||basic:show an icon||`` of a **Heart**.
13
+ Use the basic ``||basic:show icon||`` function to display the **HEART** icon. Type the code below, or drag a code snippet from the ``||basic:Basic||`` Toolbox category.
15
14
 
16
15
  ```spy
17
16
  basic.showIcon(IconNames.Heart)
18
17
  ```
19
18
 
20
- ## Step 2
19
+ ## {Step 2}
21
20
 
22
- After the icon is displayed, ``||basic:clear screen||`` and ``||basic:pause||`` for `500` milliseconds.
21
+ Use the ``||basic:clear screen||`` function followed by the ``||basic:pause||`` function to turn off the lights for **500** milliseconds (or half a second).
23
22
 
24
23
  ```spy
25
24
  basic.showIcon(IconNames.Heart)
@@ -27,9 +26,9 @@ basic.clearScreen()
27
26
  basic.pause(500)
28
27
  ```
29
28
 
30
- ## Step 3
29
+ ## {Step 3}
31
30
 
32
- Now, copy the code currently have and add it to the end. In the copied code, ``||basic:show an icon||`` of a **SmallHeart**. Your heart will flash from big to small.
31
+ Copy the code you've written and paste it at the end. In the copied code, change the ``||basic:Icon Names||`` to a **SMALL HEART**. Run your code in the on-screen micro:bit simulator. Do you see a big and small heart animation?
33
32
 
34
33
  ```spy
35
34
  basic.showIcon(IconNames.Heart)
@@ -40,23 +39,9 @@ basic.clearScreen()
40
39
  basic.pause(500)
41
40
  ```
42
41
 
43
- ## Step 4
42
+ ## {Step 4}
44
43
 
45
- Add one more ``||basic:show icon||`` at the end to display another **Heart**.
46
-
47
- ```spy
48
- basic.showIcon(IconNames.Heart)
49
- basic.clearScreen()
50
- basic.pause(500)
51
- basic.showIcon(IconNames.SmallHeart)
52
- basic.clearScreen()
53
- basic.pause(500)
54
- basic.showIcon(IconNames.Heart)
55
- ```
56
-
57
- ## Step 5
58
-
59
- Do you want your heart to flash continuously? Remove the last ``||basic:show icon||`` and then put a ``||basic:forever||`` loop around your code.
44
+ Now let's make our hearts flash forever! Put a ``||basic:forever||`` loop around your code.
60
45
 
61
46
  ```spy
62
47
  basic.forever(function() {
@@ -69,6 +54,6 @@ basic.forever(function() {
69
54
  })
70
55
  ```
71
56
 
72
- ## Step 6
57
+ ## {Step 5}
73
58
 
74
- If you have a @boardname@ connected, click ``|Download|`` and transfer your code to the @boardname@!
59
+ If you have a @boardname@ device, connect it to your computer and click the ``|Download|`` button. Follow the instructions to transfer your code onto the @boardname@ and watch the hearts flash! ⭐ Great job! ⭐
@@ -2,48 +2,66 @@
2
2
 
3
3
  ### @explicitHints true
4
4
 
5
- ## Introduction @unplugged
5
+ ## {Introduction @unplugged}
6
6
 
7
- Make a **LOVE METER** machine, how sweet! The @boardname@ is feeling the love, then sometimes not so much!
7
+ How much love 😍 are you emitting today? Create a 💓 LOVE METER 💓 machine with your micro:bit!
8
8
 
9
9
  ![Love meter banner message](/static/mb/projects/love-meter/love-meter.gif)
10
10
 
11
- ## Step 1
11
+ ## {Step 1}
12
12
 
13
- Add an event to run code when ``||input:pin 0 is pressed||``. Use the ``P0`` touchpin.
13
+ Add an input ``||input:on pin pressed||`` function to run code when Pin P0 is pressed on the micro:bit. Type the code below, or drag a code snippet from the ``||input:Input||`` Toolbox category.
14
14
 
15
15
  ```spy
16
16
  input.onPinPressed(TouchPin.P0, function() {
17
17
  })
18
18
  ```
19
19
 
20
- ## Step 2
20
+ ## {Step 2}
21
21
 
22
- Put code into the ``||input:pin 0 is pressed||`` event to ``||basic:show||`` a ``||Math:random number||``
23
- between `0` to `100` when pin **0** is pressed.
22
+ Write some code to show a number in the ``||input:on pin pressed||`` function, using the basic ``||basic:show number||`` function.
24
23
 
25
24
  ```spy
26
25
  input.onPinPressed(TouchPin.P0, function() {
27
- basic.showNumber(randint(0, 100));
28
- });
26
+ basic.showNumber(0)
27
+ })
29
28
  ```
30
29
 
31
- ## Step 3
30
+ ## {Step 3}
32
31
 
33
- Click on pin **0** in the simulator and see which number is chosen.
32
+ Instead of showing 0, use the ``||math:randint||`` function to show a random number between a minimum and maximum value.
34
33
 
35
- ## Step 4
34
+ ```spy
35
+ input.onPinPressed(TouchPin.P0, function() {
36
+ basic.showNumber(randint(0, 10))
37
+ })
38
+ ```
39
+
40
+ ## {Step 4}
36
41
 
37
- Insert code to ``||basic:show||`` the ``"LOVE METER"`` message on the screen when the program starts.
42
+ Everyone knows that love can be measured on a scale of 0 to 100. So, in the ``||math:randint||`` function, change the maximum value to **100**.
43
+
44
+ ```spy
45
+ input.onPinPressed(TouchPin.P0, function() {
46
+ basic.showNumber(randint(0, 100))
47
+ })
48
+ ```
49
+
50
+ ## {Step 5}
51
+
52
+ Now let's be sure to label our Love Machine! Use the basic ``||basic:show string||`` function to show the message "LOVE METER" on the screen of the micro:bit.
38
53
 
39
54
  ```spy
40
55
  basic.showString("LOVE METER")
41
56
  input.onPinPressed(TouchPin.P0, function() {
42
57
  basic.showNumber(randint(0, 100));
43
- });
58
+ })
44
59
  ```
45
60
 
46
- ## Step 5
61
+ ## {Step 6}
62
+
63
+ Let's test our code. Press **Pin 0** on the micro:bit on-screen simulator (bottom left). Numbers between 0-25 = 🖤 No Love, 26-50 = 🫶 BFF Love, 51-75 = 💘 Brokenhearted Love, 76-100 = 💖🔥 Fiery Hot Love!
64
+
65
+ ## {Step 7}
47
66
 
48
- Click ``|Download|`` to transfer your code in your @boardname@. Hold the **GND** pin with one hand
49
- and press pin **0** with the other hand to trigger this code.
67
+ If you have a @boardname@ device, connect it to your computer and click the ``|Download|`` button. Follow the instructions to transfer your code onto the @boardname@. Once your code has been downloaded, hold the **GND** pin with one hand and touch the **0** pin with the other hand. Your micro:bit 💓 LOVE METER 💓 machine will detect the love current flowing through your body!