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,297 @@
1
+ # Morse Chat
2
+
3
+ ## 1. Introducing Sky @unplugged
4
+
5
+ 🐷 Meet Sky, the pig! Sky can only communicate using [__*morse code*__](#morsecode "an alphabet composed of dots (short signals) and dashes (long signals)").
6
+
7
+ Luckily, you can use your @boardname@ with sound to talk to Sky 👋
8
+
9
+ ![Morse chat banner message](/static/mb/projects/morse-chat.png)
10
+
11
+ ## 2. Setup
12
+
13
+ ⚙️ **Communication works best when set up properly** ⚙️
14
+
15
+ ---
16
+
17
+ ► From the ``||input:Input||`` category in the toolbox, drag an ``||input:on logo [pressed]||`` container into to your workspace.
18
+
19
+ ► From the ``||radio:Radio||`` category, get ``||radio:radio send number [0]||`` and snap it into your empty ``||input:on logo [pressed]||`` container.
20
+
21
+ ```blocks
22
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
23
+ radio.sendNumber(0)
24
+ })
25
+ ```
26
+
27
+ ## 3. Sending different messages pt. 1
28
+
29
+ 💬 **Sending Sky two _different_ messages** 💬
30
+
31
+ ---
32
+
33
+ ► From ``||input:Input||``, grab **another** ``||input:on logo [pressed]||`` container and add it to your workspace.
34
+ 💡 This container is greyed out because it matches another. Let's change that!
35
+
36
+ ► On the greyed-out ``||input:on logo [pressed]||`` container, click on the **``pressed``** dropdown and set it to ``||input:long pressed||``.
37
+
38
+ ```blocks
39
+ // @highlight
40
+ input.onLogoEvent(TouchButtonEvent.LongPressed, function () {
41
+ })
42
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
43
+ radio.sendNumber(0)
44
+ })
45
+ ```
46
+
47
+ ## 4. Sending different messages pt. 2
48
+
49
+ ► From the ``||radio:Radio||`` category, get a ``||radio:radio send number [0]||`` block and snap it into your **empty** ``||input:on logo [long pressed]||`` container.
50
+
51
+ ► Set the number to be ``1``.
52
+
53
+ ```blocks
54
+ input.onLogoEvent(TouchButtonEvent.LongPressed, function () {
55
+ // @highlight
56
+ radio.sendNumber(1)
57
+ })
58
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
59
+ radio.sendNumber(0)
60
+ })
61
+ ```
62
+
63
+ ## 5. Receiving different messages
64
+
65
+ To ensure Sky gets the right message, we will use an [__*if then / else*__](#ifthenelse "runs some code if a boolean condition is true and different code if the condition is false") conditional statement.
66
+
67
+ ---
68
+
69
+ ► From ``||radio:Radio||``, find the ``||radio:on radio received [receivedNumber]||`` container and add it to your workspace.
70
+
71
+ ► From ``||logic:Logic||``, grab an ``||logic:if <true> then / else||`` statement and snap it into your **new** ``||radio:on radio received [receivedNumber]||`` container.
72
+
73
+ ► Go back to the ``||logic:Logic||`` category, grab ``||logic:<[0] [=] [0]>||``, and click it in to **replace** the ``||logic:<true>||`` argument in your ``||logic:if <true> then / else||`` statement.
74
+
75
+ ```blocks
76
+ radio.onReceivedNumber(function (receivedNumber) {
77
+ // @highlight
78
+ if (0 == 0) {
79
+
80
+ } else {
81
+
82
+ }
83
+ })
84
+ ```
85
+
86
+ ## 6. Conditioning on the input
87
+
88
+ ► From your ``||radio:on radio received [receivedNumber]||`` container, grab the **``receivedNumber``** input and drag out a copy.
89
+
90
+ ► Use your copy of **``receivedNumber``** to replace the ``[0]`` on the **left side** of ``||logic:<[0] [=] [0]>||``.
91
+
92
+ ```blocks
93
+ radio.onReceivedNumber(function (receivedNumber) {
94
+ // @highlight
95
+ if (receivedNumber == 0) {
96
+
97
+ } else {
98
+
99
+ }
100
+ })
101
+ ```
102
+
103
+ ## 7. Displaying a message pt. 1
104
+
105
+ 📃 **Dashing through the lights** 📃
106
+
107
+ ► We want to display a dash if the logo is long pressed. From ``||basic:Basic||``, grab ``||basic:show leds||`` and snap it into the empty **bottom container** of your ``||logic:if then / else||`` statement.
108
+
109
+ ► Turn on 3 LEDs in a row to be a dash: -
110
+
111
+ ```blocks
112
+ radio.onReceivedNumber(function (receivedNumber) {
113
+ if (receivedNumber == 0) {
114
+ } else {
115
+ // @highlight
116
+ basic.showLeds(`
117
+ . . . . .
118
+ . . . . .
119
+ . # # # .
120
+ . . . . .
121
+ . . . . .
122
+ `)
123
+ }
124
+ })
125
+ ```
126
+
127
+ ## 8. Playing a sound pt. 1
128
+
129
+ 🎵 **Adding sound** 🎵
130
+
131
+ ---
132
+
133
+ ► From the ``||music:Music||`` category, grab a ``||music:play tone [Middle C] for [1 beat]||`` block and snap it at the **end** of the **bottom container** in your ``||logic:if then / else||`` statement.
134
+
135
+ ```blocks
136
+ radio.onReceivedNumber(function (receivedNumber) {
137
+ if (receivedNumber == 0) {
138
+ } else {
139
+ basic.showLeds(`
140
+ . . . . .
141
+ . . . . .
142
+ . # # # .
143
+ . . . . .
144
+ . . . . .
145
+ `)
146
+ // @highlight
147
+ music.playTone(262, music.beat(BeatFraction.Whole))
148
+ }
149
+ })
150
+ ```
151
+
152
+ ## 9. Displaying a message pt. 2
153
+
154
+ ⚫ **Dot dot dot** ⚫
155
+
156
+ ---
157
+
158
+ ► We want to display a dot if the logo is pressed. From ``||basic:Basic||``, grab another ``||basic:show leds||`` and snap it into the **top container** of your ``||logic:if then / else||`` statement.
159
+
160
+ ► Turn on a single LED to make a dot: .
161
+
162
+ ```blocks
163
+ radio.onReceivedNumber(function (receivedNumber) {
164
+ if (receivedNumber == 0) {
165
+ // @highlight
166
+ basic.showLeds(`
167
+ . . . . .
168
+ . . . . .
169
+ . . # . .
170
+ . . . . .
171
+ . . . . .
172
+ `)
173
+ } else {
174
+ basic.showLeds(`
175
+ . . . . .
176
+ . . . . .
177
+ . # # # .
178
+ . . . . .
179
+ . . . . .
180
+ `)
181
+ music.playTone(262, music.beat(BeatFraction.Whole))
182
+ }
183
+ })
184
+ ```
185
+
186
+ ## 10. Playing a sound pt. 2
187
+
188
+ ► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat]||`` and snap it in at the **end** of the **top container** in your ``||logic:if then / else||`` statement.
189
+
190
+ ► Dots are shorter than dashes! Set the tone to play for ``1/4 beat``.
191
+
192
+ ```blocks
193
+ radio.onReceivedNumber(function (receivedNumber) {
194
+ if (receivedNumber == 0) {
195
+ basic.showLeds(`
196
+ . . . . .
197
+ . . . . .
198
+ . . # . .
199
+ . . . . .
200
+ . . . . .
201
+ `)
202
+ // @highlight
203
+ music.playTone(262, music.beat(BeatFraction.Quarter))
204
+ } else {
205
+ basic.showLeds(`
206
+ . . . . .
207
+ . . . . .
208
+ . # # # .
209
+ . . . . .
210
+ . . . . .
211
+ `)
212
+ music.playTone(262, music.beat(BeatFraction.Whole))
213
+ }
214
+ })
215
+ ```
216
+
217
+ ## 11. Clearing the screens
218
+
219
+ 🗨️ **Clear the lights once the messages are sent** 🗨️
220
+
221
+ ---
222
+
223
+ ► From ``||basic:Basic||``, find ``||basic:clear screen||`` and snap it in at the **very bottom** of your ``||radio:on radio received [receivedNumber]||`` container.
224
+
225
+ ```blocks
226
+ radio.onReceivedNumber(function (receivedNumber) {
227
+ if (receivedNumber == 0) {
228
+ basic.showLeds(`
229
+ . . . . .
230
+ . . . . .
231
+ . . # . .
232
+ . . . . .
233
+ . . . . .
234
+ `)
235
+ music.playTone(262, music.beat(BeatFraction.Quarter))
236
+ } else {
237
+ basic.showLeds(`
238
+ . . . . .
239
+ . . . . .
240
+ . # # # .
241
+ . . . . .
242
+ . . . . .
243
+ `)
244
+ music.playTone(262, music.beat(BeatFraction.Whole))
245
+ }
246
+ // @highlight
247
+ basic.clearScreen()
248
+ })
249
+ ```
250
+
251
+ ## 12. Testing in the simulator
252
+
253
+ 🐷 **Test what you've created** 💬
254
+
255
+ Remember to turn your sound on!
256
+
257
+ ---
258
+
259
+ ► Touch the gold logo at the top of your @boardname@ (it looks like a pig snout 🐽) on the simulator. You'll notice that a second @boardname@ appears.
260
+ 💡 If your screen is too small, you might not be able to see it.
261
+
262
+ ► Touch the 🐽 again to send messages to Sky 🐖
263
+ **Press** to send a dot.
264
+ **Long press** (count to 3!) to send a dash.
265
+
266
+ ► If you have multiple @boardname@s with sound (they have **shiny gold** logos at the top), download this code and try it out!
267
+
268
+ ```blocks
269
+ radio.onReceivedNumber(function (receivedNumber) {
270
+ if (receivedNumber == 0) {
271
+ basic.showLeds(`
272
+ . . . . .
273
+ . . . . .
274
+ . . # . .
275
+ . . . . .
276
+ . . . . .
277
+ `)
278
+ music.playTone(262, music.beat(BeatFraction.Quarter))
279
+ } else {
280
+ basic.showLeds(`
281
+ . . . . .
282
+ . . . . .
283
+ . # # # .
284
+ . . . . .
285
+ . . . . .
286
+ `)
287
+ music.playTone(262, music.beat(BeatFraction.Whole))
288
+ }
289
+ basic.clearScreen()
290
+ })
291
+ input.onLogoEvent(TouchButtonEvent.LongPressed, function () {
292
+ radio.sendNumber(1)
293
+ })
294
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
295
+ radio.sendNumber(0)
296
+ })
297
+ ```
@@ -0,0 +1,165 @@
1
+ # Pet Hamster
2
+
3
+ ## 1. Introduction @unplugged
4
+
5
+ 👋 Meet your new pet hamster, Cyrus 🐹
6
+
7
+ ![Pet hamster banner message](/static/mb/projects/pet-hamster.png)
8
+
9
+ ## 2. Cyrus's asleep face
10
+
11
+ 😴 **Sleeping on the job** 😴
12
+
13
+ Cyrus is a very sleepy hamster. In fact, Cyrus is almost always sleeping.
14
+
15
+ ---
16
+
17
+ ► From the ``||basic:Basic||`` category, find ``||basic:show icon [ ]||`` and snap it into your ``||basic:on start||`` container.
18
+
19
+ ► Set it to show the asleep ``-_-`` face.
20
+ 💡 In the ``show icon`` dropdown menu options, you can hover to see what each design is called!
21
+
22
+ ```blocks
23
+ basic.showIcon(IconNames.Asleep)
24
+ ```
25
+
26
+ ## 3. Giggly Cyrus
27
+
28
+ 🤣 **That tickles** 🤣
29
+
30
+ Pressing Cyrus's logo tickles them!
31
+
32
+ ---
33
+
34
+ ► From ``||input:Input||``, find the ``||input:on logo [pressed]||`` container and drag it into your workspace.
35
+
36
+ ► Go to ``||basic:Basic||`` and grab **another** ``||basic:show icon [ ]||``. Snap it into your **empty** ``||input:on logo [pressed]||`` container.
37
+
38
+ ► Set the icon (Cyrus's face) to happy ``:)``.
39
+
40
+ ```blocks
41
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
42
+ basic.showIcon(IconNames.Happy)
43
+ })
44
+ ```
45
+
46
+ ## 4. Tickle sound
47
+
48
+ 🎶 **The sounds of Cyrus** 🎶
49
+
50
+ ---
51
+
52
+ ► From the ``||music:Music||`` category, get a ``||music:play sound [giggle] until done||`` and add it to the **bottom** of your ``||input:on logo [pressed]||`` container.
53
+
54
+ ```blocks
55
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
56
+ basic.showIcon(IconNames.Happy)
57
+ // @highlight
58
+ soundExpression.giggle.playUntilDone()
59
+ })
60
+ ```
61
+
62
+ ## 5. Dizzy Cyrus
63
+
64
+ 😵 **All shaken up** 💫
65
+
66
+ Whenever Cyrus is shaken, they get sad 🙁
67
+
68
+ ---
69
+
70
+ ► From ``||input:Input||``, find ``||input:on [shake]||`` and drag it into your workspace.
71
+
72
+ ► From the ``||basic:Basic||`` category, grab ``||basic:show icon [ ]||`` and snap it into your **new** ``||input:on [shake]||`` container.
73
+
74
+ ► Set the icon (Cyrus's face) to sad ``:(``.
75
+
76
+ ```blocks
77
+ input.onGesture(Gesture.Shake, function () {
78
+ basic.showIcon(IconNames.Sad)
79
+ })
80
+ ```
81
+
82
+ ## 6. Dizzy sound
83
+
84
+ ► From the ``||music:Music||`` category, find the ``||music:play sound [giggle] until done||`` block and add it to the **bottom** of your ``||input:on [shake]||`` container.
85
+
86
+ ► Click on the **dropdown** and set it so Cyrus plays a ``||music:sad||`` sound until done.
87
+
88
+ ```blocks
89
+ input.onGesture(Gesture.Shake, function () {
90
+ basic.showIcon(IconNames.Sad)
91
+ // @highlight
92
+ soundExpression.sad.playUntilDone()
93
+ })
94
+ ```
95
+
96
+ ## 7. Cyrus's default face pt. 1
97
+
98
+ 💤 **Back to sleep** 💤
99
+
100
+ Let's ensure that Cyrus will always go back to sleep after being shaken or tickled.
101
+
102
+ ---
103
+
104
+ ► Right click the ``||basic:show icon[-_-]||`` block in your workspace (inside the ``||basic:on start||`` container) and choose **Duplicate**.
105
+
106
+ ► Snap your copied block in at the **very bottom** of your ``||input:on [shake]||`` container.
107
+
108
+ ```blocks
109
+ input.onGesture(Gesture.Shake, function () {
110
+ basic.showIcon(IconNames.Sad)
111
+ soundExpression.sad.playUntilDone()
112
+ // @highlight
113
+ basic.showIcon(IconNames.Asleep)
114
+ })
115
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
116
+ basic.showIcon(IconNames.Happy)
117
+ soundExpression.giggle.playUntilDone()
118
+ })
119
+ basic.showIcon(IconNames.Asleep)
120
+ ```
121
+
122
+ ## 8. Cyrus's default face pt. 2
123
+
124
+ ► Duplicate the ``||basic:show icon[-_-]||`` block again and this time snap it in at the **very bottom** of your ``||input:on logo [pressed]||`` container.
125
+
126
+ ```blocks
127
+ input.onGesture(Gesture.Shake, function () {
128
+ basic.showIcon(IconNames.Sad)
129
+ soundExpression.sad.playUntilDone()
130
+ basic.showIcon(IconNames.Asleep)
131
+ })
132
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
133
+ basic.showIcon(IconNames.Happy)
134
+ soundExpression.giggle.playUntilDone()
135
+ // @highlight
136
+ basic.showIcon(IconNames.Asleep)
137
+ })
138
+ basic.showIcon(IconNames.Asleep)
139
+ ```
140
+
141
+ ## 9. Testing in the simulator
142
+
143
+ 🐾 **Test what you've created** 🐾
144
+
145
+ Check out the simulator and make sure your speakers are on 🔊
146
+
147
+ Play with Cyrus to see how they react 🐹
148
+ **Click on the SHAKE button** to shake Cyrus.
149
+ **Touch the gold logo at the top** (it looks like a piggy snout 🐽) to tickle Cyrus.
150
+
151
+ If you have a new @boardname@ (the one with the **shiny gold** logo at the top), download this code and try it out!
152
+
153
+ ```blocks
154
+ input.onGesture(Gesture.Shake, function () {
155
+ basic.showIcon(IconNames.Sad)
156
+ soundExpression.sad.playUntilDone()
157
+ basic.showIcon(IconNames.Asleep)
158
+ })
159
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
160
+ basic.showIcon(IconNames.Happy)
161
+ soundExpression.giggle.playUntilDone()
162
+ basic.showIcon(IconNames.Asleep)
163
+ })
164
+ basic.showIcon(IconNames.Asleep)
165
+ ```
package/docs/projects.md CHANGED
@@ -8,6 +8,11 @@
8
8
  "imageUrl": "/static/mb/projects/a1-display.png",
9
9
  "largeImageUrl": "/static/mb/projects/flashing-heart/sim.gif"
10
10
  },
11
+ {
12
+ "name": "Tutorials for the new micro:bit (V2)",
13
+ "url": "/v2tutorials",
14
+ "imageUrl": "/static/mb/projects/pet-hamster.png"
15
+ },
11
16
  {
12
17
  "name": "Live Coding",
13
18
  "url": "/live-coding",
@@ -54,7 +59,7 @@
54
59
  "imageUrl": "/static/mb/projects/turtle-square.png"
55
60
  },
56
61
  {
57
- "name": "Blocks To JavaScript",
62
+ "name": "Blocks to JavaScript",
58
63
  "url": "/courses/blocks-to-javascript",
59
64
  "imageUrl": "/static/courses/blocks-to-javascript/hello-javascript.png"
60
65
  },
@@ -94,6 +99,7 @@
94
99
  ## See Also
95
100
 
96
101
  [Tutorials](/tutorials),
102
+ [Tutorials for the new micro:bit (V2)](/v2tutorials),
97
103
  [Live Coding](/live-coding),
98
104
  [Games](/projects/games),
99
105
  [Radio Games](/projects/radio-games),
@@ -103,7 +109,7 @@
103
109
  [Science](/projects/science),
104
110
  [Tools](/projects/tools),
105
111
  [Turtle](/projects/turtle),
106
- [Blocks To JavaScript](/courses/blocks-to-javascript),
112
+ [Blocks to JavaScript](/courses/blocks-to-javascript),
107
113
  [Courses](/courses),
108
114
  [Behind the MakeCode Hardware](/behind-the-makecode-hardware),
109
115
  [Science Experiments](/science-experiments),
@@ -1,4 +1,4 @@
1
- # Forever
1
+ # forever
2
2
 
3
3
  Keep running part of a program
4
4
  [in the background](/reference/control/in-background).
@@ -8,7 +8,20 @@ basic.forever(() => {
8
8
  })
9
9
  ```
10
10
 
11
- ## Example: compass
11
+ You can have part of a program continuously by placing it in an **forever** loop. The **forever** loop will _yield_ to the other code in your program though, allowing that code to have time to run when needs to.
12
+
13
+ ### ~ reminder
14
+
15
+ #### Event-based loops
16
+
17
+ Both the **forever** loop and the **every** loop are _event-based_ loops where the code inside is run as part of a function. These are different from the [for](/blocks/loops/for) and [while](/blocks/loops/while) loops. Those are loops are part of the programming language and can have [break](/blocks/loops/break) and [continue](/blocks/loops/continue) statements in them.
18
+ You can NOT use **break** or **continue** in either a **forever** loop or an **every** loop.
19
+
20
+ ### ~
21
+
22
+ ## Examples
23
+
24
+ ### Example: compass
12
25
 
13
26
  The following example constantly checks the
14
27
  [compass heading](/reference/input/compass-heading)
@@ -32,7 +45,7 @@ basic.forever(() => {
32
45
  })
33
46
  ```
34
47
 
35
- ## Example: counter
48
+ ### Example: counter
36
49
 
37
50
  The following example keeps showing the [number](/types/number) stored in a global variable.
38
51
  When you press button `A`, the number gets bigger.
@@ -66,5 +79,5 @@ input.onButtonPressed(Button.A, () => {
66
79
 
67
80
  ## See also
68
81
 
69
- [while](/blocks/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)
82
+ [while](/blocks/loops/while), [in background](/reference/control/in-background), [every](/reference/loops/every-interval)
70
83
 
@@ -8,7 +8,7 @@ basic.showNumber(2)
8
8
 
9
9
  ## Parameters
10
10
 
11
- * `value` is a [Number](/types/number).
11
+ * `value` is a [Number](/types/number). If the number is not single-digit number, it will scroll on the display.
12
12
  * `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
13
13
 
14
14
  ## Examples:
@@ -0,0 +1,42 @@
1
+ # every Interval
2
+
3
+ Run part of the program in a loop continuously at a time interval.
4
+
5
+ ```sig
6
+ loops.everyInterval(500, function () {})
7
+ ```
8
+
9
+ If you want to run some code continuously, but on a time interval, then use an **every** loop. You set the amount of time that the loop waits before the code inside runs again. This is similar to a [forever](/reference/basic/forever) loop, in that it runs continuously, except that there's a time interval set to wait on before the loop runs the next time. This loop is useful when you want some of a program's code run on a _schedule_.
10
+
11
+ ## Parameters
12
+
13
+ * **interval**: a [number](/types/number) that is the amount of time in milliseconds to wait before running the loop again.
14
+
15
+ ### ~ reminder
16
+
17
+ #### Event-based loops
18
+
19
+ Both the **every** loop and the **forever** loop are _event-based_ loops where the code inside is run as part of a function. These are different from the [for](/blocks/loops/for) and [while](/blocks/loops/while) loops. Those are loops are part of the programming language and can have [break](/blocks/loops/break) and [continue](/blocks/loops/continue) statements in them.
20
+ You can NOT use **break** or **continue** in either an **every** loop or a **forever** loop.
21
+
22
+ ### ~
23
+
24
+ ## Example
25
+
26
+ At every `200` milliseconds of time, check if either the **A** or **B** button is pressed. If so, show on the screen which one is pressed.
27
+
28
+ ```blocks
29
+ loops.everyInterval(200, function () {
30
+ if (input.buttonIsPressed(Button.A)) {
31
+ basic.showString("A")
32
+ } else if (input.buttonIsPressed(Button.B)) {
33
+ basic.showString("B")
34
+ } else {
35
+ basic.clearScreen()
36
+ }
37
+ })
38
+ ```
39
+
40
+ ## See also
41
+
42
+ [forever](/reference/basic/forever)
@@ -19,6 +19,7 @@ Two @boardname@s work like remote levels. They lie flat and detect any change in
19
19
  ```typescript
20
20
  let ax = 0;
21
21
  let ay = 0;
22
+ radio.setGroup(3)
22
23
  basic.forever(() => {
23
24
  ax = input.acceleration(Dimension.X);
24
25
  ay = input.acceleration(Dimension.Y);
@@ -29,6 +29,7 @@ thing from nearby @boardname@s. It shows these numbers as a
29
29
  [bar graph](/reference/led/plot-bar-graph).
30
30
 
31
31
  ```blocks
32
+ radio.setGroup(1)
32
33
  basic.forever(() => {
33
34
  radio.sendNumber(input.acceleration(Dimension.X));
34
35
  })
@@ -43,6 +44,7 @@ This program uses the signal strength from received packets to graph the
43
44
  approximate distance between two @boardname@s.
44
45
 
45
46
  ```blocks
47
+ radio.setGroup(1)
46
48
  basic.forever(() => {
47
49
  radio.sendNumber(0)
48
50
  })
@@ -23,6 +23,7 @@ https://www.youtube.com/watch?v=Re3H2ISfQE8
23
23
  This program continuously sends a cheerful message. It also receives a messages from nearby @boardname@s. It shows these messages on the screen.
24
24
 
25
25
  ```blocks
26
+ radio.setGroup(1)
26
27
  basic.forever(() => {
27
28
  radio.sendString("I'm happy");
28
29
  })
@@ -27,6 +27,7 @@ thing from nearby @boardname@s, show the numbers as a
27
27
  [bar graph](/reference/led/plot-bar-graph).
28
28
 
29
29
  ```blocks
30
+ radio.setGroup(1)
30
31
  basic.forever(() => {
31
32
  radio.sendValue("accel-x", input.acceleration(Dimension.X))
32
33
  })
@@ -28,6 +28,7 @@ This program uses the signal strength from received packets to graph the
28
28
  approximate distance between two @boardname@s.
29
29
 
30
30
  ```blocks
31
+ radio.setGroup(1)
31
32
  basic.forever(() => {
32
33
  radio.sendNumber(0)
33
34
  })
@@ -19,6 +19,7 @@ If you load this program onto two @boardname@s, each board will send the level i
19
19
  ```typescript
20
20
  let ax = 0;
21
21
  let ay = 0;
22
+ radio.setGroup(6)
22
23
  basic.forever(() => {
23
24
  ax = input.acceleration(Dimension.X);
24
25
  ay = input.acceleration(Dimension.Y);
@@ -26,6 +26,7 @@ code word from one of them to the others by pressing button `A`. The
26
26
  other @boardname@s will receive the code word and then show it.
27
27
 
28
28
  ```blocks
29
+ radio.setGroup(1)
29
30
  input.onButtonPressed(Button.A, () => {
30
31
  radio.sendString("Codeword: TRIMARAN")
31
32
  basic.showString("SENT");
@@ -20,6 +20,14 @@ to talk to each other because they will have the same group ID.
20
20
 
21
21
  * **id**: a [number](/types/number) from ``0`` to ``255``.
22
22
 
23
+ ### ~ reminder
24
+
25
+ #### Default radio group
26
+
27
+ If you haven't set a radio group for the @boardname@, it will use one selected randomly. If you are transmiting data to a @boardname@ that has a different hardware version from the sending @boardname@, it will select a random default group that is not the same as the other @boardname@. To be certain that your program will send or receive data using the same radio group, you will need to first choose and set a radio group for your program if you want it to work between different versions of the @boardname@.
28
+
29
+ ### ~
30
+
23
31
  ## Simulator
24
32
 
25
33
  This function only works on the @boardname@, not in browsers.
@@ -40,6 +40,7 @@ the second @boardname@), this program sends temperature data to the
40
40
  serial port.
41
41
 
42
42
  ```blocks
43
+ radio.setGroup(44)
43
44
  input.onButtonPressed(Button.A, function () {
44
45
  radio.sendNumber(input.temperature())
45
46
  radio.sendValue("temp", input.temperature())