How To Controlling BUZZER With Arduino

Required Hardware

For users who do not have Hackerspace Karachi Arduino KiT v1.0

  • Arduino Board
  • Buzzer
  • Resistor 220 Ohms
  • Hook-up Wires

Circuit

For users who do not have Hackerspace Karachi Arduino KiT v1.

Schematic

Code

                    

1. /*
2. Controlling BUZZER with Arduino
3.
4. This example shows how to control a BUZZER using Arduino.
5.
6. The circuit:
7. – BUZZER
8. Anode connected to analog pin Ao.
9. Cathode connected to Ground.
10.
11.
12. http://hackerspacekarachi.org/
13. */
14.
15. void setup() {
16. pinMode(A0, OUTPUT); //Declare pins to be used as output
17.
18. }
19.
20. void loop()
21. {
22.
23. tone ( A0, 450); //setting frequency
24. delay (500);
25. noTone (A0);
26. delay (500);
27.
28. }

1. /*