Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.
Created on: 13 May 2013
This article and circuit diagram show how to connect a buzzer to an Arduino when the buzzer operates at a different voltage to the Arduino. The buzzer may operate at 9V, 12V or some other voltage. Arduinos such as the Arduino Uno operate from 5V. All the voltages referred to here are d.c. voltages (direct current).
The same circuit used here can also be used to operate a 5V buzzer when the buzzer draws more current than the Arduino pin can handle, so can not be connected directly to the Arduino pin.
The circuit shown here uses a NPN transistor to connect the buzzer to the Arduino. The transistor allows the buzzer to be powered from a different voltage to the Arduino. Any NPN transistor that can handle the current drawn by the buzzer can be used.
With a PN2222 and 2k2 base resistor, the circuit can be used to operate a buzzer that draws up to about 200mA.
Although the circuit shows the buzzer being powered from 12V, the circuit allows any buzzer that operates from about 5V to around 24V to be used.
When the external power supply (12V in the circuit diagram) is connected, the GND or 0V of the power supply must be connected to the GND of the Arduino.
So the above circuit means that the connections must be made as follows:
The power supply powering the buzzer in this circuit is a 12V battery.
The Arduino sketch below operates the above circuit by pulsing the buzzer on for a short period of time continuously.
/*-------------------------------------------------------------- Program: transistor_buzzer Description: Pulses the buzzer on and off Hardware: Buzzer and NPN transistor circuit: http://startingelectronics.org/beginners/circuits/arduino-buzzer/ Software: Developed using Arduino 1.0.3 software Should be compatible with Arduino 1.0 + Date: 13 May 2013 Author: W.A. Smith, http://startingelectronics.org --------------------------------------------------------------*/ void setup() { pinMode(3, OUTPUT); // buzzer on pin 3 } void loop() { digitalWrite(3, HIGH); // switch buzzer on for 100ms delay(100); digitalWrite(3, LOW); // switch buzzer off delay(1000); }
This video shows the buzzer powered from a 9V battery and the Arduino powered from a USB cable. The Arduino is running the above sketch.
Can't see the video? View on YouTube →
As an Amazon Associate I earn from qualifying purchases: