Posts about... All (17) Android (2) Hooking Up Parts (10) Game Controllers (3) Robots (2)

How to Hook Up > Buzzers

Buzzers allow for simple audio output. Running them at different speeds allow for a variety of tones. This post details how to hook one up to an Arduino.



  1. A typical (piezo) buzzer has 2 leads. To no surprise, 1 is positive and 1 is negative. These should be labeled on and/or under the buzzer.
  2. Place it on you breadboard and place a (yellow) wire from the positive lead to a digital pin (4).
  3. Place a (black) wire from the negative lead to a ground pin.
  4. buzzer

  5. Connect the Arduino to your computer using the USB cable (A to B).
  6. The code below will repeatedly turn the buzzer on HIGH and LOW (on and off) with 2000 microseconds intervals, which is 2 milliseconds or 0.002 seconds. Upload it to your board and enjoy the constant low tone.


int buzzPin = 2;

void setup()
pinMode(buzzPin, OUTPUT);

void loop()
digitalWrite(buzzPin, HIGH);
digitalWrite(buzzPin, LOW);


Turning the buzzer on and off rapidly causes the buzzer to vibrate and make sound. While the above code is looping infinitely, using a for loop will give you more control over the duration. You’ll want to loop it at least a couple dozen times for a brief (1-2 second) sound.