How to control evive’s buzzer in Arduino IDE

evive Peizo Buzzer
About This Tutorial
This tutorial discusses what is a piezo buzzer, evive’s inbuilt buzzer, how to control it in Arduino IDE with the help of an Arduino IDE sketch.
Tutorial Info

Components Required

Image Component Quantity Available in Kit
evive 1
USB A-B Cable 1


A piezo buzzer is an electronic device that is commonly used to produce sound. The working principle behind it is the inverse effect of piezoelectricity. Piezo electricity, or the piezo electric effect is the ability of certain materials to generate electric charge when mechanical pressure is applied on them. This effect was discovered by the French scientist brothers Jacques and Pierre Curie. The word Piezoelectric is derived from the Greek piezein, which means to squeeze or press, and piezo, which is Greek for push.

One of the notable features of the piezo electric effect is that it is reversible, meaning if an electrical field is applied to the object made of piezo electric material, mechanical stress is generated, i.e. it either stretches or compresses. These deformations leads to the generation of audible sound.

evive has an inbuilt piezo buzzer. The piezo buzzer is connected to digital pin 46 of Arduino Mega and is controlled via PWM.

evive Peizo Buzzer

 Controlling Piezo Buzzer

To generate the electric signal from evive to control the buzzer, we use the tone() function. It generates a square wave of the specific frequency with a 50% duty cycle on digital pin 46. A different duty cycle can be specified otherwise. The wave continues until the noTone() function is called. 

evive Notes Icon
Only one tone can be generated at a time. If a tone is already playing on a different pin (when multiple buzzer are connected only one is played at a time), the call to tone() will have no effect. If the tone function is called on the same pin, then the call will change 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


Below are the Arduino IDE sketch showing how to use the piezo buzzer and play specific tones on Buzzer:

First example shows how to use tone() function. In this example different frequencies are played on buzzer.

In this example song of specific length is played on evive buzzer.

Share this Tutorial
Share on facebook
Share on twitter
Share on pinterest
Share on reddit
Share on print
Featured Projects

Leave a Reply