ezBuzzer Library - Melody Repeat Example
This example uses a piezo buzzer:
- Plays a melody once on background each time a button is pressed
- Stops playing a melody when another button is pressed
- Without using delay() function, this is a non-blocking example
About ezBuzzer Library
- Refer to Arduino - ezBuzzer Library Reference
- Install ezBuzzer library. See How To
- Connect Arduino to PC via USB cable
- Open Arduino IDE, select the right board and port
- On Arduino IDE, Go to File Examples ezBuzzer Melody example
- Click Upload button on Arduino IDE to upload code to Arduino
- You will hear "Jingle Bells" song repeatedly
Read the line-by-line explanation in comment lines of source code!
※ NOTE THAT:
The above example code demonstrates how to use the ezBuzzer library to make a beep on Piezo Buzzer each time button is pressed. In practice, You may need to debounce for the button. Debouncing for the button is not easy for beginners. Fortunately, thanks to the ezButton library, We can do it easily.