Beginner Series Lesson 8: Buzzers
This lesson will teach us how to use the buzzer on our CoDrone controller.  

IMG_1371

Buzzers are little speakers that can be programmed to make beeping noises.   We’ll learn how to utilize these beeps and buzzes as signals in our code.

 

Buzzers

A buzzer is a very small, simple speaker that is used to produce very simple beeping noises. On our controller, the buzzer is the small black cylinder to the left of the dip switches.

Buzzer

Buzzer

To program our buzzer, we use the command CoDrone.Buzz()

CoDrone.Buzz()

CoDrone.Buzz(Tone, Length)

Tone – The tone of the buzz noise.  A larger number will be a higher pitched buzz.

Length – The inverse length of the buzz noise.  A larger number will be a shorter buzz.

 

Making Music

Here’s an example of a code that will play a buzz tone right after the CoDrone pairs.  This will let us know when our CoDrone is connected and ready to fly.

Our signal begins with a quick middle pitched beep CoDrone.Buzz(4000,10)  , then a high pitched beep CoDrone.Buzz(8000, 10) , then a long, low pitched beep CoDrone.Buzz(2000,2) .

 

Indicator Buzzers

The best part about using a buzzer is that it gives us an easy way to track our code.  Sometimes you might be waiting for a part of your code to execute and you won’t know whether it didn’t work or it just hasn’t happened yet.  Using buzzers as indicators will help us narrow down the problems in our programs.

When using IR sensors as triggers, it’s useful to include a buzz

This way we know if our Stop command is actually executing.

 

We can also use the various tones to tell us which step of the code we’re on.  Here’s an example of an autonomous flight code that will buzz with a higher pitch after each maneuver.

In the next lesson, we’ll use learn how write our own controller flight code.

Activity: Raise the Roof!

Using if-statements, IR sensors, and CoDrone.Buzz() , turn your controller into a music making machine.  Assign each IR sensor a different buzz tone and try to play a song. with it.

Digital IR Sensors Pins

Remember, a larger Tone value results in a higher pitch, while a larger Length value results in a shorter beep.