In this experiment, we will again bridge the gap between the digital world and the analog world. We’ll be using a piezo buzzer that makes a small “click” when you apply voltage to it (try it!). By itself that isn’t terribly exciting, but if you turn the voltage on and off hundreds of times a second, the passive buzzer will produce a tone. And if you string a bunch of tones together, you’ve got music! This circuit and set of code blocks will create a simple sound machine.
The buzzer is a small component with a piece of metal in it that moves when you apply a voltage across it. This motion causes a small sound, or “click.”
If you turn the voltage on and off fast enough, you get different beeps, squeals, chirps and buzzes. You will use PWM to control the speed of turning the piezo on and off — and, in turn, the audio frequency coming out of the buzzer. Adjusting the PWM enables you to get legitimate notes out of the buzzer.
If you flip the buzzer over and look at the bottom, you will see that one pin has a (+) next to it. That pin gets connected to a signal from the P0 pin. The other pin should be connected to ground.
Note: We use the buzzer module in this project.
Ready to start hooking everything up? Check out the wiring diagram below to see how everything is connected.
First, please plug Osoyoo Magic I/O shield into UNO board:
Then connect the Passive Buzzer module to the D8 port of the Magic I/O shield with a 3-pin PNP cable as below:
Connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on. Open the Mixly and choose corresponding board type and port type for you project.
If you realize the block is too long, you can right click to choose “Collapse Block” to shorten it.
The whole program blocks are as following:
Or you can Click here to download the code, please known that you should open Mixly first, and then click “open” in the software to choose the code you download, otherwise it may cause error.
After above operations are completed, do as follows:
A few seconds after the upload finishes, you will hear the buzzer beep.
DownLoad Url osoyoo.com