03 - Buzzer
Overview
The on-board buzzer is a passive buzzer that controls the sound of a pleasant melody through different frequencies<br />
Usage
Building Block Introduction
Programming Building Block | Function Introduction |
---|---|
Specify the frequency and playing time | |
Continuous playing of the specified frequency | |
Play specified melody | |
Play built-in melody | |
Use with continuous playback |
Case 1 - SOS Distress Call
Effect: Pressing the button triggers an alarm, attracting attention from the surrounding area.
Programming Blocks
Case 1 - Playing a Melody
- Introduction to the prerequisites, taking c4:2 as an example
- c: British nomenclature, representing the pitch, corresponding to do~xi respectively. An octave is roughly divided into these 7 pitches: cdefab.
- 4: Octave, for example, 4 is the fourth octave.
- :2: Duration, with the default bpm=120 and quarter note as one beat, 1 second is 2 beats => 0.5 seconds/beat, so 2 represents half of a quarter note, so the duration of this c4:2 is 0.25s.
- Each note is separated by a space.
- Programming blocks
Click on the blocks below to play the first part of the melody of "Twinkle, Twinkle, Little Star". Try to complete the next part yourself~
<br />
c4:2 c4:2 g4:2 g4:2 a4:2 a4:2 g4 g4 - Reference simple notation
Example 1 - Playing Built-In Melodies
Effect: Use these preset melodies to add some musicality to your programs more conveniently<br />