pxt-microbit 4.0.12 → 4.0.13

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.
Files changed (37) hide show
  1. package/built/hexcache/{b2e08efad14a6680dc3a2942b93acef42d2045d9f2907e7fe5926264d0c04310.hex → 6526a3337377701ca7bf1d9940f76fdccac145405380ee3ecc2c96f6049e34ce.hex} +10240 -10251
  2. package/built/hexcache/{8cf431acbfd0538188a30333695c29dc120ffe3e58cc5c076bdf928db97027da.hex → 8fc8a1499d69a5d8cc851cf49d16112b3021ab801238204dacf84073acf90e7c.hex} +10835 -10846
  3. package/built/target-strings.json +2 -1
  4. package/built/target.js +38 -30
  5. package/built/target.json +38 -30
  6. package/built/targetlight.json +5 -5
  7. package/docs/blocks/comments.md +131 -0
  8. package/docs/blocks/loops.md +12 -0
  9. package/docs/extensions.md +40 -0
  10. package/docs/projects/SUMMARY.md +7 -1
  11. package/docs/projects/micro-chat.md +8 -8
  12. package/docs/projects/mood-radio.md +3 -1
  13. package/docs/projects/multi-dice.md +8 -6
  14. package/docs/projects/plot-acceleration.md +2 -2
  15. package/docs/projects/v2-blow-away.md +317 -0
  16. package/docs/projects/v2-clap-lights.md +195 -0
  17. package/docs/projects/v2-countdown.md +151 -0
  18. package/docs/projects/v2-morse-chat.md +297 -0
  19. package/docs/projects/v2-pet-hamster.md +165 -0
  20. package/docs/projects.md +8 -2
  21. package/docs/reference/basic/forever.md +17 -4
  22. package/docs/reference/basic/show-number.md +1 -1
  23. package/docs/reference/loops/every-interval.md +42 -0
  24. package/docs/reference/radio/on-received-buffer.md +1 -0
  25. package/docs/reference/radio/on-received-number.md +2 -0
  26. package/docs/reference/radio/on-received-string.md +1 -0
  27. package/docs/reference/radio/on-received-value.md +1 -0
  28. package/docs/reference/radio/received-packet.md +1 -0
  29. package/docs/reference/radio/send-buffer.md +1 -0
  30. package/docs/reference/radio/send-string.md +1 -0
  31. package/docs/reference/radio/set-group.md +8 -0
  32. package/docs/reference/radio/write-received-packet-to-serial.md +1 -0
  33. package/docs/reference/radio/write-value-to-serial.md +1 -0
  34. package/docs/v2tutorials.md +39 -0
  35. package/package.json +1 -1
  36. package/pxtarget.json +1 -1
  37. package/targetconfig.json +23 -6
@@ -0,0 +1,317 @@
1
+ # Blow Away
2
+
3
+ ## 1. Introduction pt. 1 @unplugged
4
+
5
+ 👻 Oh, no! Your @boardname@ is being haunted by a ghost named Haven 👻
6
+
7
+ For this tutorial, we'll learn how to blow Haven away 🌬️
8
+
9
+ ![Blow away banner message](/static/mb/projects/blow-away.png)
10
+
11
+ ## 2. Haunted ghost setup
12
+
13
+ 🏚️ **BooOooOoo** 🏚️
14
+
15
+ A wild Haven has appeared!
16
+
17
+ ---
18
+
19
+ ► From the ``||basic:Basic||`` category, find ``||basic:show icon [ ]||`` and add it to your ``||basic:on start||`` container.
20
+
21
+ ► Click the heart icon and set it to show a ghost.
22
+ 💡 In the ``show icon`` dropdown menu options, you can hover to see what each design is called.
23
+
24
+ ```blocks
25
+ // @highlight
26
+ basic.showIcon(IconNames.Ghost)
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 3. Loop setup
32
+
33
+ ➰ **Looping around** ➰
34
+
35
+ ---
36
+
37
+ ► From the ``||loops:Loops||`` category, find the ``||loops:repeat [4] times||`` loop and snap it into your empty ``||basic:forever||`` container.
38
+ 💡 Why do we need a [__*repeat loop*__](#repeatLoop "repeat code for a given number of times") when we already have a ``forever`` container? Because ``forever`` has an embedded delay that we want to avoid!
39
+
40
+ ```blocks
41
+ basic.forever(function () {
42
+ // @highlight
43
+ for (let index = 0; index < 4; index++) {
44
+
45
+ }
46
+ })
47
+ ```
48
+
49
+ ## 4. Conditional setup
50
+
51
+ 🤔 **Conditioning and comparing** 🤔
52
+
53
+ Haven hates noise and will blow away if things get too loud. Let's use an [__*if statement*__](#ifstatement "if this condition is met, do something") to check for sounds.
54
+
55
+ ---
56
+
57
+ ► From ``||logic:Logic||``, grab an ``||logic:if <true> then||`` statement and snap it into your empty ``||loops:repeat [4] times do||`` loop.
58
+
59
+ ► Go back to ``||logic:Logic||`` to get a ``||logic:<[0] [=] [0]>||`` comparison.
60
+
61
+ ► Snap ``||logic:<[0] [=] [0]>||`` in to **replace** the ``||logic:<true>||`` condition for your ``||logic:if then||`` statement.
62
+
63
+ ```blocks
64
+ basic.forever(function () {
65
+ // @highlight
66
+ for (let index = 0; index < 4; index++) {
67
+ // @highlight
68
+ if (0 == 0) {
69
+
70
+ }
71
+ }
72
+ })
73
+ ```
74
+
75
+ ## 5. Blow sound
76
+
77
+ 👂 **Haven's ears** 👂
78
+
79
+ We'll be using a [__*sound threshold*__](#soundThreshold "a number for how loud a sound needs to be to trigger an event. 0 = silence to 255 = maximum noise") to act as Haven's ears.
80
+
81
+ ---
82
+
83
+ ► From the ``||input:Input||`` category, drag ``||input:sound level||`` in to **replace** the **_left_ ``0``** of your ``||logic:<[0] [=] [0]>||`` comparison.
84
+
85
+ ► Using the dropdown in the **middle** of ``||logic:[sound level] [=] [0]||``, change the comparison to be **``>``** (greater than).
86
+
87
+ ► Finally, have the **right side** of the comparison say ``128`` so your full comparison reads: **``sound level > 128``**.
88
+ 💡 This means Haven will hear any sound above ``128``.
89
+
90
+ ```blocks
91
+ basic.forever(function () {
92
+ for (let index = 0; index < 4; index++) {
93
+ // @highlight
94
+ if (input.soundLevel() > 128) {
95
+
96
+ }
97
+ }
98
+ })
99
+ ```
100
+
101
+ ## 6. Making variables
102
+
103
+ ☀️ **Variable weather** 🌨️
104
+
105
+ Let's create some [__*variables*__](#variable "a holder for information that may change") to keep track of Haven's movement.
106
+
107
+ ---
108
+
109
+ ► In the ``||variables:Variables||`` category, click on ``Make a Variable...`` and make a variable named ``col``.
110
+ 💡 ``col`` is short for "column".
111
+
112
+ ► Make **another** variable and name it ``row``.
113
+
114
+ ## 7. Displacing LEDs part 1
115
+
116
+ 🔀 **Random chance** 🔀
117
+
118
+ To show Haven is blowing away, we want to move a random set of lights sideways.
119
+
120
+ ---
121
+
122
+ ► Your ``||variables:Variables||`` category should now have the option to ``||variables:set [row] to [0]||``. Drag that block into your empty ``||logic:if then||`` statement.
123
+
124
+ ► From the ``||math:Math||`` category, find ``||math:pick random [0] to [10]||`` and snap that in to **replace** the ``[0]`` in your ``||variables:set [row] to [0]||`` block.
125
+
126
+ ► Change the maximum number from ``10`` to **``4``**.
127
+ 💡 We are setting the maximum random value to 4 because the lights on the @boardname@ are numbered 0, 1, 2, 3, and 4 for columns and rows.
128
+
129
+ ```blocks
130
+ let row = 0
131
+ basic.forever(function () {
132
+ for (let index = 0; index < 4; index++) {
133
+ if (input.soundLevel() > 128) {
134
+ // @highlight
135
+ row = randint(0, 4)
136
+ }
137
+ }
138
+ })
139
+ ```
140
+
141
+ ## 8. Displacing LEDs part 2
142
+
143
+ ► Go back into ``||variables:Variables||`` and drag out another ``||variables:set [row] to [0]||``. Place this one below the last one (at **the end**) of your `if then` statement.
144
+
145
+ ► Using the **dropdown menu**, set the new block to read ``||variables:set [col] to [0]||``.
146
+
147
+ ► From the ``||math:Math||`` category, grab another ``||math:pick random [0] to [10]||`` and snap that in to **replace** the ``[0]`` in your ``||variables:set [col] to [0]||`` block.
148
+
149
+ ► Change the maximum number from ``10`` to **``4``**.
150
+
151
+ ```blocks
152
+ let col = 0
153
+ let row = 0
154
+ basic.forever(function () {
155
+ for (let index = 0; index < 4; index++) {
156
+ if (input.soundLevel() > 128) {
157
+ row = randint(0, 4)
158
+ // @highlight
159
+ col = randint(0, 4)
160
+ }
161
+ }
162
+ })
163
+ ```
164
+
165
+ ## 9. Conditioning on one point
166
+
167
+ ✨ **Ooh, sparkly** ✨
168
+
169
+ Time to move some lights around!
170
+
171
+ ---
172
+
173
+ ► From ``||logic:Logic||``, grab another ``||logic:if <true> then||`` and snap it at the **inside and at the bottom of** your ``||loops:repeat [4] times do||`` loop, right below your ``||logic:if [sound level] [>] [128]||`` statement.
174
+
175
+ ► From the ``||led:Led||`` category, find ``||led:point x [0] y [0]||`` and drag it in to **replace** the ``||logic:<true>||`` condition in the **new** ``||logic:if then||`` statement.
176
+ 💡 This block will test if the light is on at the the given ``x`` and ``y`` coordinate points.
177
+
178
+ ```blocks
179
+ let col = 0
180
+ let row = 0
181
+ basic.forever(function () {
182
+ for (let index = 0; index < 4; index++) {
183
+ if (input.soundLevel() > 128) {
184
+ row = randint(0, 4)
185
+ col = randint(0, 4)
186
+ }
187
+ // @highlight
188
+ if (led.point(0, 0)) { }
189
+ }
190
+ })
191
+ ```
192
+
193
+ ## 10. Unplotting and replotting LEDs
194
+
195
+ To create the animation effect of Haven blowing away, we will turn off (or ``unplot``) a light that is on and then turn it on again (``plot`` it) in a different spot.
196
+
197
+ ---
198
+
199
+ ► From ``||led:Led||``, grab ``||led:unplot x [0] y [0]||`` and snap it inside the **empty** ``||logic:if <point x [0] y [0]> then||`` statement.
200
+
201
+ ► Go back to ``||led:Led||`` and get ``||led:plot x [0] y [0]||``. Snap that in **beneath** the ``||led:unplot x [0] y [0]||`` block that you just added.
202
+
203
+ ```blocks
204
+ let col = 0
205
+ let row = 0
206
+ basic.forever(function () {
207
+ for (let index = 0; index < 4; index++) {
208
+ if (input.soundLevel() > 128) {
209
+ row = randint(0, 4)
210
+ col = randint(0, 4)
211
+ }
212
+ // @highlight
213
+ if (led.point(0, 0)) {
214
+ led.unplot(0, 0)
215
+ led.plot(0, 0)
216
+ }
217
+ }
218
+ })
219
+ ```
220
+
221
+ ## 11. Setting variables
222
+
223
+ 📃 **Columns and rows** 📃
224
+
225
+ Notice how you have **three** blocks from the ``||led:Led||`` category. All three have ``||led:x||`` ``[0]`` and ``||led:y||`` ``[0]`` coordinates. In these **two** steps, we will set it so that every ``||led:x||`` is followed by the ``||variables:col||`` variable and every ``||led:y||`` is followed by the ``||variables:row||`` variable.
226
+
227
+ ---
228
+
229
+ ► From ``||variables:Variables||``, get three copies of ``||variables:col||``, and use them to **replace the ``x`` values** in the following three blocks:
230
+ **1.** ``||led:point x [0] y [0]||``
231
+ **2.** ``||led:unplot x [0] y [0]||``
232
+ **3.** ``||led:plot x [0] y [0]||``
233
+
234
+ ► Go into ``||variables:Variables||``, get three copies of ``||variables:row||``, and use them to **replace the ``y`` values** in the same three blocks.
235
+
236
+ ```blocks
237
+ let col = 0
238
+ let row = 0
239
+ basic.forever(function () {
240
+ for (let index = 0; index < 4; index++) {
241
+ if (input.soundLevel() > 128) {
242
+ row = randint(0, 4)
243
+ col = randint(0, 4)
244
+ }
245
+ // @highlight
246
+ if (led.point(col, row)) {
247
+ led.unplot(col, row)
248
+ led.plot(col, row)
249
+ }
250
+ }
251
+ })
252
+ ```
253
+
254
+ ## 12. Moving LEDs
255
+
256
+ ➕ **Math makes the lights go swoosh** ➗
257
+
258
+ Right now, we are unplotting and replotting in the same spot. What we want to do is move the lights we're turning back on just a smidge to the right every time until there's nothing left on the grid.
259
+
260
+ ---
261
+
262
+ ► From ``||math:Math||``, find the ``||math:[0] [+] [0]||`` operation and use it to **replace** ``||variables:col||`` in your ``||led:plot x [col] y [row]||`` block.
263
+ 💡 If you move your entire ``||basic:forever||`` container, you should find a greyed out ``col`` variable in your workspace.
264
+
265
+ ► Take the greyed out ``||variables:col||`` variable (or get a new one) and use it to **replace** the **_first_ ``[0]``** so the operation reads ``||math:[col] [+] [0]||``.
266
+
267
+ ► Replace the **_second_ ``[0]``** with **``[1]``** so the operation reads ``||math:[col] [+] [1]||``.
268
+
269
+ ```blocks
270
+ let col = 0
271
+ let row = 0
272
+ basic.forever(function () {
273
+ for (let index = 0; index < 4; index++) {
274
+ if (input.soundLevel() > 128) {
275
+ row = randint(0, 4)
276
+ col = randint(0, 4)
277
+ }
278
+ // @highlight
279
+ if (led.point(col, row)) {
280
+ led.unplot(col, row)
281
+ led.plot(col + 1, row)
282
+ }
283
+ }
284
+ })
285
+ ```
286
+
287
+ ## 13. Testing in the simulator
288
+
289
+ 🌬️ **Test what you've created** 👻
290
+
291
+ Check out the simulator!
292
+
293
+ ---
294
+
295
+ ► Click on the pink bar underneath the microphone icon. Drag it above the sound number you chose (we used ``128``!) to blow Haven away.
296
+
297
+ ► If you have a new @boardname@ (the one with the **shiny gold** logo at the top), download this code and try it out!
298
+ 💡 Blow close to the @boardname@ and watch Haven swoosh away 💨
299
+ 💡 Use your @boardname@'s reset button (it's on the back!) to bring Haven back 👻
300
+
301
+ ```blocks
302
+ let col = 0
303
+ let row = 0
304
+ basic.showIcon(IconNames.Ghost)
305
+ basic.forever(function () {
306
+ for (let index = 0; index < 4; index++) {
307
+ if (input.soundLevel() > 128) {
308
+ row = randint(0, 4)
309
+ col = randint(0, 4)
310
+ }
311
+ if (led.point(col, row)) {
312
+ led.unplot(col, row)
313
+ led.plot(col + 1, row)
314
+ }
315
+ }
316
+ })
317
+ ```
@@ -0,0 +1,195 @@
1
+ # Clap Lights
2
+
3
+ ## 1. Introduction @unplugged
4
+
5
+ The new @boardname@s have a microphone to help them detect sound 🎤
6
+
7
+ Let's learn how to use a clap 👏 to switch your @boardname@'s lights on and off!
8
+
9
+ ![Clap lights banner message](/static/mb/projects/clap-lights.png)
10
+
11
+ ## 2. Setting up the sound input
12
+
13
+ 🔊 **Reacting to sound** 🔊
14
+
15
+ ---
16
+
17
+ ► From the ``||input:Input||`` category, find the ``||input:on [loud] sound||`` container and add it to your workspace.
18
+
19
+ ```blocks
20
+ input.onSound(DetectedSound.Loud, function () {
21
+
22
+ })
23
+ ```
24
+
25
+ ## 3. Creating a lightsOn variable
26
+
27
+ 🤿 **Diving right in** 🤿
28
+
29
+ Let's begin by creating a [__*variable*__](#variable "a holder for information that may change") to keep track of whether the @boardname@'s lights are on or off.
30
+
31
+ ---
32
+
33
+ ► In the ``||variables:Variables||`` category, click on ``Make a Variable...`` and make a variable named ``lightsOn``.
34
+
35
+ ## 4. Displaying LEDs part 1
36
+
37
+ 🔆 **On or not?** 🌑
38
+
39
+ In this step, we'll be using an [__*if then / else*__](#ifthenelse "runs some code if a Boolean condition is true and different code if the condition is false") statement.
40
+
41
+ ---
42
+
43
+ ► From the ``||logic:Logic||`` category, grab an ``||logic:if <true> then / else||`` block and snap it into your ``||input:on [loud] sound||`` container.
44
+
45
+ ► Look in the ``||variables:Variables||`` category. Find the new ``||variables:lightsOn||`` variable and snap it in to **replace** the ``||logic:<true>||`` value in your ``||logic:if <true> then / else||`` statement.
46
+
47
+ ```blocks
48
+ let lightsOn = 0
49
+ input.onSound(DetectedSound.Loud, function () {
50
+ // @highlight
51
+ if (lightsOn) {
52
+
53
+ } else {
54
+
55
+ }
56
+ })
57
+ ```
58
+
59
+ ## 5. Displaying LEDs part 2
60
+
61
+ 🌞 **Lighting the display** 🌞
62
+
63
+ ---
64
+
65
+ ► From ``||basic:Basic||``, grab ``||basic:show leds||`` and snap it into the **top container** of your ``||logic:if then / else||`` statement.
66
+
67
+ ► Set the lights to a pattern you like!
68
+ 💡 In the hint, we chose to turn on all of the outside lights. Feel free to make your own design 🎨
69
+
70
+ ```blocks
71
+ let lightsOn = 0
72
+ input.onSound(DetectedSound.Loud, function () {
73
+ if (lightsOn) {
74
+ // @highlight
75
+ basic.showLeds(`
76
+ # # # # #
77
+ # . . . #
78
+ # . . . #
79
+ # . . . #
80
+ # # # # #
81
+ `)
82
+ } else {
83
+ }
84
+ })
85
+ ```
86
+
87
+ ## 6. Clearing the screen
88
+
89
+ ► From ``||basic:Basic||``, find ``||basic:clear screen||`` and snap it into the **bottom container** of your ``||logic:if then / else||`` section.
90
+ 💡 This will turn the display off if ``lightsOn`` is **not** ``true``.
91
+
92
+ ```blocks
93
+ let lightsOn = 0
94
+ input.onSound(DetectedSound.Loud, function () {
95
+ if (lightsOn) {
96
+ basic.showLeds(`
97
+ # # # # #
98
+ # . . . #
99
+ # . . . #
100
+ # . . . #
101
+ # # # # #
102
+ `)
103
+ } else {
104
+ // @highlight
105
+ basic.clearScreen()
106
+ }
107
+ })
108
+ ```
109
+
110
+ ## 7. Setting the lightsOn variable
111
+
112
+ 🎬 **Lights, camera, _action_** ✨
113
+
114
+ Just like we'd toggle a light switch, each time we clap, we want to **flip** the variable ``lightsOn`` to the **opposite** of what it was before.
115
+
116
+ ---
117
+
118
+ ► From ``||variables:Variables||``, locate ``||variables:set [lightsOn] to [0]||`` and snap it in at the **very top** of your ``||input:on [loud] sound||`` container.
119
+
120
+ ► From the ``||logic:Logic||`` category, find the ``||logic:not <>||`` operator and use it to **replace the ``[0]``** in ``||variables:set [lightsOn] to [0]||``.
121
+
122
+ ► From ``||variables:Variables||``, grab ``||variables:lightsOn||`` and snap it into the **empty part** of the ``||logic:not <>||`` operator.
123
+
124
+ ```blocks
125
+ let lightsOn = false
126
+ input.onSound(DetectedSound.Loud, function () {
127
+ // @highlight
128
+ lightsOn = !(lightsOn)
129
+ if (lightsOn) {
130
+ basic.showLeds(`
131
+ # # # # #
132
+ # . . . #
133
+ # . . . #
134
+ # . . . #
135
+ # # # # #
136
+ `)
137
+ } else {
138
+ basic.clearScreen()
139
+ }
140
+ })
141
+ ```
142
+
143
+ ## 8. Testing in the simulator
144
+
145
+ 💡 **Test what you've created** 💡
146
+
147
+ ---
148
+
149
+ ► Check out the simulator!
150
+
151
+ ► Click on the pink slider bar beneath the microphone icon and drag it up and down.
152
+ 💡 Right now, your @boardname@ thinks that anything above 128 is loud. Every time the sound goes > 128, your lights should switch on/off.
153
+
154
+ ## 8. Set loud sound threshold
155
+
156
+ Your @boardname@ might detect sounds when you don't want it to. Setting a [__*sound threshold*__](#soundThreshold "a number for how loud a sound needs to be to trigger an event. 0 = silence to 255 = maximum noise") could help 🔉🔊
157
+
158
+ ---
159
+
160
+ ► Click on the ``||input:Input||`` category. A new category should show up beneath it called ``||input:...more||``.
161
+
162
+ ► From ``||input:...more||``, grab ``||input:set [loud] sound threshold to [128]||`` and snap it into your **empty** ``||basic: on start||`` container.
163
+ 💡 Try to change the value of your sound threshold so that every time you clap, your lights will turn on if they are off and vice versa.
164
+
165
+ ```blocks
166
+ // @highlight
167
+ input.setSoundThreshold(SoundThreshold.Loud, 150)
168
+ ```
169
+
170
+ ## 9. Testing, round 2
171
+
172
+ 👏 **YOU DID IT!** 👏
173
+
174
+ Don't forget to test your code in the simulator!
175
+
176
+ If you have a new @boardname@ (the one with the **shiny gold** logo at the top), download this code and try it out!
177
+
178
+ ```blocks
179
+ let lightsOn = false
180
+ input.onSound(DetectedSound.Loud, function () {
181
+ lightsOn = !(lightsOn)
182
+ if (lightsOn) {
183
+ basic.showLeds(`
184
+ # # # # #
185
+ # . . . #
186
+ # . . . #
187
+ # . . . #
188
+ # # # # #
189
+ `)
190
+ } else {
191
+ basic.clearScreen()
192
+ }
193
+ })
194
+ input.setSoundThreshold(SoundThreshold.Loud, 150)
195
+ ```
@@ -0,0 +1,151 @@
1
+ # Countdown
2
+
3
+ ## 1. Introduction @unplugged
4
+
5
+ 🎇3...🎇2...🎇1...
6
+ 🎆GO!🎆
7
+
8
+ Let's create a musical countdown using the new @boardname@ with sound!
9
+
10
+ ![Countdown banner message](/static/mb/projects/countdown.png)
11
+
12
+ ## 2. Setting up the loop
13
+
14
+ ➰ **All looped up** ➰
15
+
16
+ We'll begin by using a [__*for loop*__](#forLoop "repeat code for a given number of times using an index") to recreate the same sound 3 times.
17
+
18
+ ---
19
+
20
+ ► From the ``||loops:Loops||`` category in your toolbox, find the ``||loops:for [index] from 0 to [4]||`` loop and add it to your ``||basic:on start||`` container.
21
+
22
+ ► Change your loop to count from ``0`` to **``2``**.
23
+ 💡 This means the loop will count 0-1-2 instead of what we want, which is 3-2-1. We will worry about this later!
24
+
25
+ ```blocks
26
+ // @highlight
27
+ for (let index = 0; index <= 2; index++) {
28
+
29
+ }
30
+ ```
31
+
32
+ ## 3. Play music
33
+
34
+ 🎵 **Musical loops** 🎵
35
+
36
+ ---
37
+
38
+ ► From ``||music:Music||``, grab ``||music:play tone [Middle C] for [1 beat]||`` and snap it into your empty ``for`` loop.
39
+ 💡 Your simulator might start playing music. You can mute it if distracting.
40
+
41
+ ► 1 beat is a little long. Use the **dropdown** to set the tone to play for ``||music:1/4 beat||``.
42
+
43
+ ```blocks
44
+ for (let index = 0; index <= 2; index++) {
45
+ // @highlight
46
+ music.playTone(262, music.beat(BeatFraction.Quarter))
47
+ }
48
+ ```
49
+
50
+ ## 4. Showing a number
51
+
52
+ ✨ **Razzle dazzle down** ✨
53
+
54
+ With every tone, we also want to **display** our countdown.
55
+
56
+ ---
57
+
58
+ ► From ``||basic:Basic||``, find ``||basic:show number [0]||`` and snap it in at the **bottom** of your ``for`` loop.
59
+
60
+ ► From your ``||loops:for [index] from 0 to [2]||`` loop condition, click and drag out the **red** ``||variables:index||`` variable.
61
+
62
+ ► Use the ``||variables:index||`` that you dragged out to **replace** the ``0`` in ``||basic:show number [0]||``.
63
+
64
+ ```blocks
65
+ for (let index = 0; index <= 2; index++) {
66
+ music.playTone(262, music.beat(BeatFraction.Quarter))
67
+ // @highlight
68
+ basic.showNumber(index)
69
+ }
70
+ ```
71
+
72
+ ## 5. Inverting the number
73
+
74
+ If you take a look at your simulator, you'll notice the @boardname@ flashing 0-1-2. We want it to say 3-2-1! Let's learn a trick to change that.
75
+
76
+ ---
77
+
78
+ ► From the ``||math:Math||`` category, snap ``||math:[0] - [0]||`` in to **replace** ``||variables:index||`` in your ``||basic:show number [index]||`` block.
79
+ 💡 You should now have a greyed out ``index`` variable in your workspace. We'll use that in the next step.
80
+
81
+ ► Pick up the greyed out ``||variables:index||`` variable and snap it in to the **right side** of your ``||math:[0] - [0]||`` operator.
82
+ 💡 Can't find ``||variables:index||``? Try moving your ``||basic:on start||`` container to see if ``||variables: index||`` is hiding behind it!
83
+
84
+ ► Set the **left side** of your ``||math:[0]-[index]||`` operator to **``3``**.
85
+ 💡 Why does this work? Every time we loop, our ``index`` variable will grow by 1 and our @boardname@ will output: 3-0 = **3** ➡️ 3-1 = **2** ➡️ 3-2 = **1**!
86
+
87
+ ```blocks
88
+ for (let index = 0; index <= 2; index++) {
89
+ music.playTone(262, music.beat(BeatFraction.Quarter))
90
+ // @highlight
91
+ basic.showNumber(3 - index)
92
+ }
93
+ ```
94
+
95
+ ## 6. Printing "GO!"
96
+
97
+ 🏁 **You had me at "GO!"** 🏁
98
+
99
+ ---
100
+
101
+ ► From ``||basic:Basic||``, grab ``||basic:show string ["Hello!"]||`` and snap it into the **very bottom** of your ``||basic:on start||`` container.
102
+
103
+ ► Replace ``Hello!`` with the word ``GO!``
104
+
105
+ ```blocks
106
+ for (let index = 0; index <= 2; index++) {
107
+ music.playTone(262, music.beat(BeatFraction.Quarter))
108
+ basic.showNumber(3 - index)
109
+ }
110
+ // @highlight
111
+ basic.showString("GO!")
112
+ ```
113
+
114
+ ## 7. Adding a "GO!" noise
115
+
116
+ 🏇 **And we're off!** 🏇
117
+
118
+ ---
119
+
120
+ ► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat]||`` and place it **above** your ``||basic:show string ["GO!"]||`` block and **below** your ``||loops:for||`` loop.
121
+ 💡 This will let your @boardname@ play the sound and show ``GO!`` at the same time.
122
+
123
+ ► Set the ``||music:tone||`` to be ``Middle G``.
124
+ 💡 ``Middle G`` is also tone ``392``.
125
+
126
+ ```blocks
127
+ for (let index = 0; index <= 2; index++) {
128
+ music.playTone(262, music.beat(BeatFraction.Quarter))
129
+ basic.showNumber(3 - index)
130
+ }
131
+ // @highlight
132
+ music.playTone(392, music.beat(BeatFraction.Whole))
133
+ basic.showString("GO!")
134
+ ```
135
+
136
+ ## 8. Testing in the simulator
137
+
138
+ 🚦 **Test what you've created** 🚦
139
+
140
+ Make sure your speakers are on and check out the simulator!
141
+
142
+ If you have a @boardname@ with sound (the one with the **shiny gold** logo at the top), no need to plug in an external speaker - just download this code and try it out!
143
+
144
+ ```blocks
145
+ for (let index = 0; index <= 2; index++) {
146
+ music.playTone(262, music.beat(BeatFraction.Quarter))
147
+ basic.showNumber(3 - index)
148
+ }
149
+ music.playTone(392, music.beat(BeatFraction.Whole))
150
+ basic.showString("GO!")
151
+ ```