You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 09ce5a3
Browse filesBrowse the repository at this point in the historyBrowse files
1.**Predict** what you think will happen. Be specific.
35
+
2.**Run** the program.
36
+
3. Time to **investigate** the code. What does each line do?
37
+
29
38
```{admonition} Code explanation
30
39
:class: notice
31
40
- **line 3** → imports the music module
@@ -57,12 +66,21 @@ NOTE[octave][:duration]
57
66
58
67
For example, `"A1:4"` means note `A`, octave `1`, duration `4`.
59
68
60
-
Make a list of notes to create a melody. This is similar to creating an animation with a list of images. For example, this code plays the opening of "Frere Jacques":
69
+
Make a list of notes to create a melody. This is similar to creating an animation with a list of images. For example, this code plays the opening of "Frere Jacques".
70
+
71
+
1. Stop and close the current **main.py** file.
72
+
2. Navigate to the **15_music_custom** folder in Thonny and open the **main.py** file.
This example uses the `music.pitch()` method. It needs a frequency. For example, `440` is the frequency of the note A used by many musicians when tuning instruments.
82
105
106
+
1.**Predict** what you think will happen. Be specific.
107
+
2.**Run** the program.
108
+
3. Time to **investigate** the code. What does each line do?
109
+
83
110
```{admonition} Code explanation
84
111
:class: notice
85
112
- **line 3** → imports the music module
@@ -101,12 +128,21 @@ Full details can be found at the **[BBC micro:bit MicroPython Speech documentati
101
128
102
129
### Say
103
130
104
-
The simplest way to get the micro:bit to speak is to import the speech module and use the `say()` function like this:
131
+
The simplest way to get the micro:bit to speak is to import the speech module and use the `say()`.
132
+
133
+
1. Stop and close the current **main.py** file.
134
+
2. Navigate to the **15_speech_say** folder in Thonny and open the **main.py** file.
1.**Predict** what you think will happen. Be specific.
143
+
2.**Run** the program.
144
+
3. Time to **investigate** the code. What does each line do?
145
+
110
146
```{admonition} Code explanation
111
147
:class: notice
112
148
- **line 3** → imports the speech module
@@ -124,12 +160,19 @@ Together, these settings control the **timbre** of the voice. Timbre means the s
124
160
125
161
To adjust the settings, pass them into the `say()` function. **[More details can be found in the speech module API documentation](https://microbit-micropython.readthedocs.io/en/latest/speech.html#timbre)**.
126
162
163
+
1. Stop and close the current **main.py** file.
164
+
2. Navigate to the **15_speech_say_2** folder in Thonny and open the **main.py** file.
1.**Predict** what you think will happen. Be specific.
173
+
2.**Run** the program.
174
+
3. Time to **investigate** the code. What does each line do?
175
+
133
176
```{admonition} Code explanation
134
177
:class: notice
135
178
- **line 3** → imports the speech module
@@ -145,12 +188,19 @@ When you use phonemes, you write the word the way it sounds, not the way it is n
145
188
146
189
A **[full list of phonemes](https://microbit-micropython.readthedocs.io/en/latest/speech.html#phonemes)** is available in the speech documentation. You can also pass English words into the **[translate function](https://microbit-micropython.readthedocs.io/en/latest/speech.html#speech.translate)**. It returns a first version of the phonemes that the speech synthesiser would use. You can then edit the result to improve how it sounds.
147
190
191
+
1. Stop and close the current **main.py** file.
192
+
2. Navigate to the **15_speech_pronounce** folder in Thonny and open the **main.py** file.
193
+
148
194
The `pronounce()` function is used for phoneme output like this:
1.**Predict** what you think will happen. Be specific.
201
+
2.**Run** the program.
202
+
3. Time to **investigate** the code. What does each line do?
203
+
154
204
```{admonition} Code explanation
155
205
:class: notice
156
206
- **line 3** → imports the speech module
@@ -165,12 +215,21 @@ The mapping from pitch numbers to musical notes is shown below:
165
215
166
216

167
217
168
-
Annotations work by adding a hash sign (`#`) and a pitch number before the phoneme. The pitch stays the same until a new annotation is given. For example, this code makes MicroPython sing a scale:
218
+
Annotations work by adding a hash sign (`#`) and a pitch number before the phoneme. The pitch stays the same until a new annotation is given.
219
+
220
+
1. Stop and close the current **main.py** file.
221
+
2. Navigate to the **15_sing** folder in Thonny and open the **main.py** file.
222
+
223
+
In this example, the code makes MicroPython sing a scale:
Copy file name to clipboardExpand all lines: 11_radio.md
+33-7Lines changed: 33 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,19 +23,45 @@ When a micro:bit receives a message, it is placed in a message **queue**. A comp
23
23
24
24
## Example
25
25
26
-
The example below shows how radio messages work. One micro:bit sends a message, and the other micro:bit displays an image. Run the same code on two micro:bits.
26
+
The example below shows how radio messages work. One micro:bit sends a message, and the other micro:bit displays an image.
27
+
28
+
On two seprate micro:bits:
29
+
1. Stop and close the current **main.py** file.
30
+
2. open the **main.py** file in the **16_radio** folder in Thonny.
2. Open the **main.py** file in the **16_radio_exercise_1** folder in Thonny.
43
+
3. Write code to move an image between two micro:bits when one micro:bit is shaken.
33
44
34
-
1. Move an image between two micro:bits when one micro:bit is shaken.
35
-
2. Use the micro:bit radio feature to send a private yes or no answer.
45
+
## Radio Exercise 2
46
+
47
+
On two separate micro:bits:
48
+
1. Stop and close the current **main.py** file.
49
+
2. Open the **main.py** file in the **16_radio_exercise_2** folder in Thonny.
50
+
3. Write code to use the micro:bit radio feature to send a private yes or no answer.
36
51
- Choose either **yes** or **no** and send it to another micro:bit.
37
52
- Display the answer on the other micro:bit for half a second.
38
53
- Use **[`radio.config`](https://microbit-micropython.readthedocs.io/en/v2-docs/radio.html#radio.config)** to choose a group so other nearby micro:bits do not receive your message.
39
-
3. Use two micro:bits to display the outdoor and indoor temperatures.
40
-
- The **outdoor micro:bit** should take a temperature reading and transmit it every 5 seconds.
41
-
- The **indoor micro:bit** should display the indoor temperature when button **A** is pressed, or the outdoor temperature when button **B** is pressed.
54
+
55
+
## Radio Exercise 3
56
+
57
+
On one micro:bit:
58
+
1. Stop and close the current **main.py** file.
59
+
2. Open the **main.py** file in the **16_radio_exercise_3/inside** folder in Thonny.
60
+
3. Write code to display the indoor temperature when button **A** is pressed.
61
+
62
+
On a differnt micro:bit:
63
+
1. Stop and close the current **main.py** file.
64
+
2. Open the **main.py** file in the **16_radio_exercise_3/outside** folder in Thonny.
65
+
3. Write code to take a temperature reading and transmit it every 5 seconds.
66
+
67
+
Place the outside micro:bit outside and the inside micro:bit inside. When you press button **A** on the inside micro:bit, it should display the temperature reading from the inside micro:bit. When you press button **B**, it should display the outdoor temperature.
0 commit comments