The last Finch output is the buzzer. You can you the buzz() method to play a tone on the Finch’s internal buzzer. This method requires two parameters. The first is the frequency of the sound; keep in mind that humans can only hear sounds in the range of 20 to 20,000 Hz. The second parameter is the duration of the sound in milliseconds. This method will start the buzzer and then immediately move on to the next line of code.
Resources available for teachers. Get Access
Write a program to make the Finch move forward, then back. When the Finch is moving forward, it should make a low-pitched buzz. When the Finch is moving back, it should make a high-pitched buzz.
If you want the Finch to play tones without moving, you can separate the tones using the sleep() method. This method pauses the program for the number of milliseconds. For example, the code below plays two tones. Without the sleep() commands, these tones would overlap. The number of milliseconds for each sleep() command is slightly longer than the number of milliseconds for each buzz so that the tones will be slightly separated.
Write a program to make the Finch play a short song. Choose a song from this website and make the Finch play your song using its buzzer!
In addition to buzz(), there is also a similar Finch method called playTone() that will play a sound using your computer speakers instead of the Finch buzzer. The parameters for this method are the same.
Practice all of the things you have learned about the Finch! Write a program to make the Finch move in a triangle, pentagon, or other shape. The Finch should buzz as it starts each side of the shape. For an added challenge, make the beak change to a different random color for each side of the shape.
Make the Finch dance! Write a script to make the Finch move and change its beak color. Use the buzzer to add sound!