Introduction
What you will need - Hardware
For this tutorial you will need:
|
The Circuit
The connections are pretty easy, see the image above with breadboard circuit schematic.
The code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* Arduino tutorial - Passive Buzzer Module More info and circuit: http://www.ardumotive.com Dev: Giannis Vasilakis // Date: 12/11/2017 */ int buzzer = 8 ; void setup () { pinMode (buzzer, OUTPUT) ; } void loop () { unsigned char i, j ; while (1) { for (i = 0; i <80; i++) // When a frequency sound { digitalWrite (buzzer, HIGH) ; //send tone delay (1) ; digitalWrite (buzzer, LOW) ; //no tone delay (1) ; } for (i = 0; i <100; i++) { digitalWrite (buzzer, HIGH) ; delay (2) ; digitalWrite (buzzer, LOW) ; delay (2) ; } } } |
Download the code from here and open it with Arduino IDE.
|
|
Well done!
You have successfully completed one more Arduino "How to" tutorial and you learned how to use the passive buzzer module. I hope you liked this, let me know in the comments.