What is a buzzer?
|The buzzer is a component which can produce sounds at different frequencies. They are used to produce signals or alerts in a wide range of systems, as well alarm clock, doorbells and timers in home appliances (such as ovens), etc.|
Operating the buzzer
Now let´s take a look at how the buzzer works. First of all, we need to connect this component as shown in the image below.
In the Components tab, we will select the Sound the buzzer block. Then we drag it to the Loop tab and select which note we want and how long it will sound for. For example, we have selected the notes Do, Re, Mi, Fa, Sol, La and Si.
You will notice that the buzzer sounds continuously. Remember that the Loop tab executes the program indefinitely, so if we only want it to go off once, it should be placed under the Setup tab instead.
A step further
Now let´s make the buzzer sound when we want it to, by using a push-button.
Once the components are connected, we need to go to the Control tab and select the If… do block so that we can program the buzzer to sound only when the button is pressed.
Look carefully at the next example, where we have used a different block to make the buzzer sound. This block is located in the Components tab, under Advanced, and it enables you to enter a frequency value rather than notes so that you can compose more elaborate melodies.
The first part of this Advanced block can be programmed in various ways. We can indicate which pin number the buzzer is connected to, or we can use the Components -> Advanced -> Variable components block and choose the name of the buzzer.
So what are you waiting for? Have a go at programming your favourite tunes! In this post, you will find various scores to get you started, and there´s also a tool to translate musical notes to frequencies. Get stuck in!
And there´s more
- Here´s a few more ideas so you can keep on practising:
- Improve your fairy lights by adding a melody that plays in sync with the flashing.
- Build your own telegraph using an LED, a push-button and the buzzer.
You´ll soon see how useful adding sounds to your creations can be… And not to mention how much fun you can have with these components! Now we´re ready and able to design projects which are much more creative, surprising and… noisy!