How to Program the Buzzer

This lesson will go over how to program the buzzer found installed in the Smart Inventor Board

First, begin the code by including the smart inventor library. Enter the following before the [crayon-661a1ae0afdf8176910837-i/] method.

Learn More: What’s a library?

A library is a saved set of [crayon-661a1ae0afe1d473505851-i/]  and variables that provide users with improved functionality when coding.

Any code that starts with [crayon-661a1ae0afe1e883216364-i/]  is a function in the SmartInventor library.  Any variable that highlights ORANGE, is an initialized variable from an included library.

Learn More

Next, inside  [crayon-661a1ae0afe20134568590-i/] , enter the following to use the buzzer to make noise. The following code will allow you to make a low pitched tone.

SmartInventor.Buzz( )

SmartInventor.Buzz( Frequency, Tempo);

This function will allow you to input numbers for the frequency and tempo and based on those values you can manipulate the sound that the buzzer makes.

Frequency is the amount of vibrations that the buzzer will make within a designated time. Acceptable numbers will range from 0 to 9,223,372,036,854,775,807.

Tempo is the speed at which you want the frequency to occur. Acceptable numbers will range from 0 to 2,147,483,647.

Next, you input a [crayon-661a1ae0afe23319731647-i/] to assign a time step for when the next noise should play.
Next, we will try making a higher pitched tone, and place another delay immediately after.
This should provide you with a program that will make both a high and low pitch.


Try to make your own song using the buzzer.

Final Code