evive has 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.
To generate the electric signal form 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)
tone(pin, frequency, duration)
To illustrate the use of piezo buzzer please see the following code: