Make some noise!
Congratulations! You now have the basic concepts needed to get our safe working! There is only one thing left to do: to figure out how to output sound for an alarm.
We are going to use an output sound using a device called a buzzer:
Image source: https://www.robomart.com/image/cache/catalog/RM0338/piezo-buzzer-b-10n-piezo-electric-buzzers-rm0338-by-robomart-399-500x500.jpg
A buzzer is a two-terminal device, meaning it has to have two connections going up to it. This buzzer also has polarity, meaning it should be connected with one particular terminal of the two connected to 5V or HIGH
, and the other connected to ground or LOW
.
Let's hook up a circuit and make some noise!
Connect the components to the breadboard as shown. Make sure the pin of the buzzer near the + sign of the buzzer goes into the I/O pin of the Arduino. This pin is usually the longer one of the two.
The other pin would be connected to the Arduinos ground:
We shall now write a code that will bring the buzzer...