This lesson learns to use Python programming to let the micro:bit emit a voice.
from microbit import *
speech.say("Hi, I'm an excellent robot from Yahboom.")
In the program,import speech is means to import the speech library function, use the speech.say function in the library to play "Hi, I'm an excellent robot from Yahboom".
"Hi, I'm an excellent robot from Yahboom" Change to whatever you want to play.
Programming and downloading：
1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure 8-1.
2.As shown in Figure 8-2, you need to click the Check button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.
3.You need to connect the micro data cable to micro:bit and the computer, then click the Flash button to download the program to micro:bit as shown in Figure 8-3.
4.After downloading the program into micro:bit, you can see a smiley face on the robot's dot matrix and make a sound: Hi, I'm an excellent robot from Yahboom.
We need to use headphones or speakers to hear the sound. The two wiring methods are as shown below.
The code of the experiment: 8.microbit voice talk.zip
Micro Python Basic Course
- Micro Python Basic Course 1.Hello,World
- Micro Python Basic Course 2: Display built-in image
- Micro Python Basic Course 3: Display custom image
- Micro Python Basic Course 4: Display custom animation
- Micro Python Basic Course 5: Button game
- Micro Python Basic Course 6: Do not touch me
- Micro Python Basic Course 7: Play built-in music
- Micro Python Basic Course 8: micro:bit voice talk