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-67589f32a90ad118409207-i/] method.
[crayon-67589f32a90b5552973872/]

Learn More: What’s a library?

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

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

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-67589f32a90bc467829760-i/] to assign a time step for when the next noise should play.
[crayon-67589f32a90bd181563223/]
Next, we will try making a higher pitched tone, and place another delay immediately after.
[crayon-67589f32a90c0453595119/]
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-67589f32a90c1357306250/]