This lesson we will learn how to control buzzer of Tiny-bit microbit robot to whistle.
1.The position of the buzzer on the robot car
2.The micro:bit pins connected to the buzzer.
From the hardware interface manual, we can know that the buzzer is directly driven by the micro:bit P0 pin.
from microbit import *
for freq in range(880, 1760, 16):
for freq in range(1760, 880, -16):
Programming and downloading：
1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure4-1.
Note! All English and symbols should be entered in English, and the last line must be a space.
2.As shown in Figure 4-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.
4.After downloading the program, we can hear the Tiny-bit car start to whistle.
The code of the experiment:4.Whistle.zip
Micro python Robot Course：
- Micro python Robot Course 1: Light up a LED
- Micro python Robot Course 2: LED light exchange lighting
- Micro python Robot Course 3.Breathing light
- Micro python Robot Course 4: Whistle
- Micro python Robot Course 5: Play《Little Star》
- Micro python Robot Course 6: Sound sensor
- Micro python Robot Course 7: Black line control light
- Micro python Robot Course 8: Measuring worker