FREE SHIPPING OVER $89; 10% OFF FOR YOUR FIRST ORDER (CODE:NEW10); $20 OFF OVER $179 (CODE:BL20); $30 OFF OVER $259(CODE:BL30)



Microbit Python Tutorials 10: microbit voice talk

Posted by SuFiona on

Course10-micro:bit voice talk

Learning goals:

This lesson learns to use Python programming to let the micro:bit emit a voice.

Code

from microbit import *

import speech

display.show(Image.HAPPY)

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 10-1.

image.png 

Figure 10-1

2.As shown in Figure 10-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.

image.png 

Figure 10-2

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 10-3.

image.png 

Figure 10-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.

image.png 

Figure 10-4

image.png 

Figure 10-5

Headphone interface:

image.png 

The code of the experiment:10.microbit voice talk.rar

 

0 comments

Leave a comment

Please note, comments must be approved before they are published