Doorbell

Start 

This project will use the piezo buzzer and a button to create a doorbell

Modules 

Gather the following parts to complete this project.

Parts

All Parts
All Parts
Piezo Buzzer
Button
Cable
PartQuantity
Piezo Buzzer 1
Button 1
Cable 2

Doorbell 

Take a cable and unwrap it. Plug one side into the buzzer socket and the other into Digital socket D6. Take another cable and unwrap it. Plug one side into the button socket and the other into Digital socket D5.

All the parts you'll need
All the parts you'll need
Take a cable...
... and unwrap it
Plug one side into the buzzer socket
... and the other into Digital socket D5
Take a cable...
... and unwrap it
Plug one side into the button socket
... and the other into Digital socket D6

Upload

Upload the code below. The example below uses the 5 and 6 digital pins. You can use any digital pin just remember to update the sketch.

Download file Copy to clipboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//If you use any different socket change them below
#define buttonSocket 5 // <- Socket for button
#define buzzerSocket 6// <- Socket for piezo buzzer

void setup()
{
  pinMode(buttonSocket, INPUT);
  pinMode(buzzerSocket, OUTPUT);
}

void loop()
{
  digitalWrite(buzzerSocket, digitalRead(buttonSocket));
}

Observe

Press the button and listen to the annoying buzzer go.

The finished doorbell
The finished doorbell
Not pressing the button and no sound
The buzzer plays once pressed
I would race to door if I kept hearing this thing

Modify

Use some tape to mount the button outside a door and the rest of the components inside.

Doorbell++ 

Some doorbells play a melody when rung. Buy changing just the code we can do that too.

Upload

Upload the code below. The example below uses the 5 and 6 digital pins. You can use any digital pin just remember to update the sketch.

Download file Copy to clipboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//If you use any different sockets change them below
#define buttonSocket 5 // <- Socket for button
#define buzzerSocket 6// <- Socket for piezo buzzer

void setup()
{
  pinMode(buttonSocket, INPUT);
  pinMode(buzzerSocket, OUTPUT);
}

void loop()
{
  if (digitalRead(buttonSocket)) {
    tone(buzzerSocket, 196);
    delay(600);
    tone(buzzerSocket, 329);
    delay(600);
    tone(buzzerSocket, 261);
    delay(600);
  } else {
    noTone(buzzerSocket);
  }
}

Observe

Now press the button. You'll hear a 3 note chime.

Modify

By changing the notes and their duration you can put together your own doorbell melodies and chimes.