What is a buzzer?
An output component that emits buzzing sounds with different frequencies. Do you remember the old computers that had internal loudspeakers? That´s the sound!
Buzzers can be found in:
- Alarms clocks
- Alarm systems
|The buzzer is one of the most fun elements you will find in the ZUM Kit! We will now give a series of examples that will enable you to become an expert in buzzers. You will need:
Making the buzzer buzzer
Let´s start with the easiest example, making the buzzer produce sounds with different tones. We will connect the buzzer like this:
Using the block corresponding to the buzzer, we will select the pin that we have connected it to (which, in this case, is pin 13), the tone and the duration that we want to sound to last for. On this occasion, we have selected the tones DO, RE, MI, but you don´t have to use these ones!
Curiosity: Somebody turn it off, please! When executing this program, the buzzer emits the tones DO, RE, MI, but instead of stopping, it continues emitting these sounds indefinitely. This happens because the program has not instructed the buzzer to stop and so when it reaches the end, it keeps on running in a loop. In the next example, we will learn how to control when the sounds are emitted, for example, when we press a particular button.
Making a buzzer sound on pushing the button
Let´s make the buzzer sound at the moment we want. To do this, we will connect both the buzzer and the button to the board, as the diagram shows:
Once the components are connected, we will use the block if..do which you are already familiar with. We will make a program so that the buzzer sounds only when the button is pressed:
Now you know how to program the buzzer! At this point, you will realise that the notes can be changed and tunes can be created. In fact, you have a second block that lets to you directly select the value of the frequency and so special notes. For sure you won´t be able to resist the temptation to have a go yourself… We certainly couldn´t! So here you get one melody for free! Want to know which one? Here´s the .xml file with the tune… you better get programming!