Piezo Buzzer

June 2, 2017

Introduction

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 a 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.

Syntax:

tone(pin, frequency)

tone(pin, frequency, duration)

Parameters:

  • 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

Example

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

How to Control Piezo Buzzer in PictoBlox (Scratch)

play tone on () of note () & beat () block is used to play sound on the 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).

play tone

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.

Example

Playing tone using touch pins in Scratch mode.

touch example 2

 

Share this Documentation
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Tutorials & Projects
play tone

play tone on () of note () & beat ()

When the block 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).
All articles loaded
No more articles to load
Featured Projects

DIY Pinball Game Machine

IntroductionAnd we’re back to make your weekend merrier with another one of the most popular…
Arcade-Basketball-Game

DIY Arcade Basketball Game

Introduction“We don’t stop playing because we grow old; we grow old because we stop playing.”…
All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart