

For more information on the Arduino random() function, go here. This ensures that we will have a different order of song selections for our doorbell. Since nothing is connected to this input, there will be a "random", fluctuating voltage on this pin providing our random number generator with many different values. We will seed our random number generator with the voltage value on analog input 0. Seeding our random number generator means feeding it a random input. We also want to "seed" our random number generator for randomly selecting a tune when someone rings our doorbell. We want to configure pin 2 as an input for our button, and we want to configure pin 8 as an output for our speaker. In the setup() function, we want to configure the digital pins for our button and our speaker. Below are the descriptions of each of the functions with snapshots of the code. More information is provided in this article. They are only connected vertically when pressed. Remember: pushbuttons are connected horizontally internally. The other side of the pushbutton will be connected to ground through a 10 kOhm pulldown resistor. We will connect one side of the pushbutton to 5V. For more information on pullup or pulldown resistors, you can read this article. By using the pulldown resistor, the Arduino reads the voltage as 0V when the button is not pressed and 5V when the button is pressed. We will use a 10 kOhm external pulldown resistor for the switch, so there is no floating voltage or unstable state on the input to the Arduino.
BUTTON BUZZER ARDUINO INSTALL
Next, we will install the pushbutton for the doorbell. We will connect the other end of the passize buzzer to ground. We want to connect the positive end of the passive buzzer (denoted by "+" sign) to digital pin 8 on the Arduino.


We will start with the passive buzzer (i.e.
