
Doorbell with a Buzzer
Beginner20 minA doorbell that plays a four-note "ding-dong" on a passive buzzer when you press the button; every ring is also written to the Serial Monitor. It teaches making sound with tone(), keeping notes and their lengths in arrays and playing them with a for loop, gathering a job into its own function, and reading a button with the Arduino's built-in pull-up resistor (INPUT_PULLUP). You can make the tune your own by changing the notes in the code. No extra library needed.

What you need
1 × Arduino Uno R3
1 × Breadboard 830 Points (MB-102)
1 × Passive Buzzer (Piezo)
1 × 12x12 mm Push Button
5 × Jumper Wire - Male/Male
Wiring steps
- 1
Connect the common ground (GND)

Plug a black jumper wire into the GND pin next to pin 13 on the Arduino's digital header. Connect its other end to the breadboard's top blue (−) rail. The button's and the buzzer's ground wires will go into this rail too.
- Arduino GND → the top blue (−) rail (black wire)
- 2
Add and wire the button

Seat the button over the middle gap of the breadboard: two legs in the top half and two in the bottom half, in columns 5 and 7. Connect the Arduino's pin 2 to column 5 in the bottom half with a green jumper wire (BUTTON_PIN 2). Then connect column 7 in the top half to the top (−) rail with a short black wire. Because you use two diagonal legs of the button, it works whichever way round it sits; no extra resistor is needed either, the Arduino's built-in one (INPUT_PULLUP) is enough.
- push button → across the middle gap, columns 5 and 7
- Arduino pin 2 → column 5, bottom half (green wire)
- column 7, top half → the top blue (−) rail (black wire)
- 3
Add and wire the buzzer

Plug the passive buzzer's + leg into column 15 in the top half and its other leg into column 16; the + leg is usually the longer one and the body has a + mark. Connect the Arduino's pin 8 to column 15 with an orange jumper wire (BUZZER_PIN 8). Then connect column 16 to the top (−) rail with a short black wire. A passive buzzer makes no sound on its own: tone() switches the pin on and off hundreds of times a second, and the buzzer vibrates at that rate, which is the note you hear.
- buzzer + leg → column 15, top half
- buzzer − leg → column 16, top half
- Arduino pin 8 → column 15, top half (orange wire)
- column 16, top half → the top blue (−) rail (black wire)
Arduino sketch
Download the sketch (.ino)Try it on Wokwi
// The button's and the buzzer's pins
const int BUTTON_PIN = 2;
const int BUZZER_PIN = 8;
// The bell's notes (Hz): E, C, D, G
const int MELODY[] = {659, 523, 587, 392};
// How long each note lasts (ms)
const int DURATIONS[] = {400, 400, 400, 800};
const int NOTE_COUNT = 4;
int rings = 0;
void setup() {
// Pull-up: a pressed button reads LOW
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("Doorbell ready: press the button");
}
// Plays the notes one after another
void playMelody() {
for (int i = 0; i < NOTE_COUNT; i++) {
tone(BUZZER_PIN, MELODY[i], DURATIONS[i]);
// Let it end, then a short pause
delay(DURATIONS[i] + 50);
}
noTone(BUZZER_PIN);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
rings++;
Serial.print("Ring: ");
Serial.println(rings);
playMelody();
// Wait until the button is let go
while (digitalRead(BUTTON_PIN) == LOW) {
delay(10);
}
// Let the contacts settle on release
delay(50);
}
}
What the Serial Monitor shows
Doorbell ready: press the button Ring: 1 Ring: 2 Ring: 3
What you will see
Every press makes the buzzer play a four-note "ding-dong" (E, C, D, G), and the Serial Monitor shows how many times it has rung. Holding the button down does not ring it again; let go and press again. If there is no sound at all, check that the buzzer is a passive one and its + leg is in column 15 (the same column as pin 8's wire). If text reaches the Serial Monitor but there is no sound, the problem is on the buzzer's side; if nothing happens when you press the button, check that it sits over the middle gap, the green wire is in column 5 and the black wire in column 7.
Similar projects
Toggle an LED with a ButtonBeginner20 minTurn a red LED on and off with a button: every press flips the LED, and the press count and the LED's state are written to the Serial Monitor. It teaches reading a button with digitalRead, the Arduino's built-in pull-up resistor (INPUT_PULLUP), catching the moment a button is pressed and waiting out contact bounce (debounce). The button needs no extra resistor, and no extra library is needed.Open project
Weather StationIntermediate40 minA small weather station for a room or a balcony: the BME280 sensor measures temperature, humidity and air pressure, and the Arduino works out the approximate altitude from the pressure. The readings show page by page on a 16x2 LCD; each press of the button turns to the next page, and the values refresh every two seconds. It teaches building an I2C line where two modules share the same two wires (SDA and SCL), working out altitude from pressure, and updating an LCD without flicker. Install "Adafruit BME280 Library" (with the extra libraries it asks for) and "LiquidCrystal I2C" from the Library Manager.Open project
Parking SensorIntermediate45 minLike the parking sensor in a car: the HC-SR04 measures the distance to whatever is in front of it, the buzzer starts beeping once something comes within 1 metre and the beeps get faster as it comes closer; below 10 cm the tone is steady. Green, yellow and red LEDs show the far, middle and near zones, and the distance is written to the Serial Monitor. It teaches timing with millis() instead of delay, so measuring, beeping and the lights run without waiting for each other, writing a function that returns a value, splitting into zones with if / else if, and turning the distance into a beep gap with map. No extra library needed.Open project
In the app, tick off every wire, match the parts to your inventory and pick up where you left off.
