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-662a7ce342975637548505-i/] method.
[crayon-662a7ce34297b283800124/]

Learn More: What’s a library?

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

Any code that starts with [crayon-662a7ce34297e042465579-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-662a7ce342980479048857-i/] , enter the following to use the buzzer to make noise. The following code will allow you to make a low pitched tone.
[crayon-662a7ce342981841636983/]

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-662a7ce342982363628150-i/] to assign a time step for when the next noise should play.
[crayon-662a7ce342983457402958/]
Next, we will try making a higher pitched tone, and place another delay immediately after.
[crayon-662a7ce342986259400957/]
This should provide you with a program that will make both a high and low pitch.

Activity:

Try to make your own song using the buzzer.

Final Code

[crayon-662a7ce342987766529120/]