Piezo Buzzer

Piezo Buzzer

Piezo Buzzer

June 2, 2017


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 Notes Icon
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.

How to Control Piezo Buzzer in Arduino IDE

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:

How to Control Piezo Buzzer in Scratch

Play tone block is used to play sound on evive buzzer. When it is executed it plays the tone of specified frequency/note for a specific duration/beat. The note and the beat can be selected from the drop down menu. Also the user can input the specific frequency and duration (in milliseconds).

There is an inbuilt buzzer in evive connected to digital pin 46. By default, this pin is selected.

This block can be used in Arduino Mode as well as in Scratch Mode.


Playing tone using keyboard pins in Scratch mode.

Playing tone using keyboard pins in Scratch mode.

Share this Page
Related Tutorials
Featured Projects
Drip Irrigation System
Drip Irrigation System

Introduction Drip irrigation system is a type of micro-irrigation of soil which has the potential to save water and nutrients by allowing water to drip slowly to the roots of

Explore this Project

Leave a Reply

Leave a Reply

Close Menu