keyestudio
Share your creative ideas with us here
By Alisa | 20 May 2024 | 0 Comments

How to Make Passive Buzzer Play Music with Micro:bit?

Overview
 

In this project, you will learn how to play music with keyestudio passive buzzer module. We are going to complete two experiments.

One is to directly control the High and Low level input of micro:bit P0 end, set waves to control the buzzer sound. The other is to use the software’s own function, input the square waves of different frequencies and different lengths on the P0 end. Finally make the buzzer module play the song “Ode to Joy”. (The input PIO port can only be P0, can not be other interfaces).
 

Component Required:
 

  • Micro:bit main board*1

  • Keyestudio Micro bit Sensor V2 Shield*1

  • USB Cable*1

  • keyestudio Passive Buzzer Module*1

  • Dupont jumper wire*3

  • Premium Battery Holder 6-cell AA*1

  • 1.5V AA Battery*6


Passive Buzzer Module:

Img

Buzzers can be categorized as active and passive ones. The difference between the two is that an active buzzer has a built-in oscillating source, so it will generate a sound when electrified. The buzzer used on this module is a passive buzzer. A passive buzzer does not have such a source, so DC signal cannot drive it beep. Instead, you need to use square waves whose frequency is between 2K and 5K to drive it. Different frequencies produce different sounds. You can use micro:bit to code the melody of a song, quite fun and simple.


Connection Diagram
 

6


Test Code
 

Program 1:
 

Program 2:
 

Img

Img

Img

Note: on the MakeCode Block webpage, click the icon, you can see the frequency of each tone as follows.


Test Results
 

Done wiring and powered up, send the code 1 to micro:bit, you should hear two sounds produced from passive buzzer circularly. If send the code 2 to micro:bit, the buzzer will play the song Ode To Joy! Really amazing. Right? You can try to change the tone to play other music.

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code