Piezo Buzzer

evive has an inbuilt piezo buzzer, which is an electronic device commonly used to produce sound or tone. The piezo buzzer is connected to digital pin 46 of Arduino Mega and is controlled via PWM.

evive Peizo Buzzer
The theory behind piezo buzzer:
Piezo buzzer is based on the inverse principle of piezoelectricity discovered in 1880 by Jacques and Pierre Curie. It is the phenomena of generating electricity when mechanical pressure is applied to certain materials. The vice versa is also true. Such materials are called piezoelectric materials. Piezo-ceramic is a class of manmade material, which poses piezoelectric effect and is widely used to make a disc, the heart of piezo buzzer. When subjected to an alternating electric field they stretch or compress, in accordance with the frequency of the signal thereby producing sound.

Controlling Piezo Buzzer:

To generate the electric signal from evive to control evive, we use tone() function. It generates a square wave of the specific frequency with a 50% duty cycle on digital pin 46. A duration can be specified, otherwise, the wave continues until a call to noTone().  Only one tone can be generated at a time. If a tone is already playing on a different pin, the call to tone() will have no effect. If the tone is playing on the same pin, the call will set its frequency.

The frequency range is from 31 Hz to 65535 Hz.


tone(pin, frequency)
tone(pin, frequency, duration)


  • pin: the pin on which to generate the tone
  • frequency: the frequency of the tone in hertz – unsigned int
  • duration: the duration of the tone in milliseconds (optional) – unsigned long


To illustrate the use of piezo buzzer please see the following code: