
Lesson 4: Making the Buzzer go BEEP
Just like the LED module, Buzzer is also an output module, instead of lighting up it produces a
beep sound. This can be used for many situations for indication purposes. We studied the use of
potentiometer in the last section, so how do we use the potentiometer to control the volume of
the buzzer? This requires the used of PWM control!
Background Information:
What is PWM
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
Digital control is used to create a square wave, a signal switched between on and off. This on-off
pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion
of the time the signal spends on versus the time that the signal spends off. The duration of “on
time” is called the pulse width. To get varying analog values, you change, or modulate, that pulse
width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the
signal is a steady voltage between 0 and 5v controlling the brightness of the LED. Reference:
As the diagram indicates below, use
analogWrite()
to generate PWM waves, the higher the
percentage of Duty Cycle, the louder the buzzer.
There are six digital pins on your Seeeduino that are marked with the symbol “~”, which means
they can send out a PWM signal : 3,5,6,9,10,11. They are celled PWM pins.
24
Grove Beginner Kit For Arduino
®