The Working Prototype
I began work on trying to create a working prototype with the Arduino.
The first thing I did was plan options as to what features I wanted from the Hands-Free doorbell. These were:
Touch Free - Even from a distance
A Buzzer - To alert the homeowner that there is somebody at their door
An Alert Light - To alert the homeowner visually, as well as via sound.
A Silent Button - A button which can be pressed to toggle the doorbell between loud and silent.
I required the following components to create my prototype:
I started by writing the code alone. Without adding any accessories or components. I did this to ensure that my main focus was on the code and making it work properly. I did this by setting all the variables for the pin to '0' for correct and issue-free code.
After writing my code, I added the Ultrasonic Sensor, and began to test the distance that this can measure. Doing this testing and printing the values in the Serial Monitor allowed me to identify the best distance away from the doorbell for activating it without touch. Upon testing, I decided that the best distance was going to be 100cm.
Upon calculating this, I added the LED, and wired everything to the breadboard, to ensure my code worked with the components, and ensuring the components were wired up correctly.
When placing my hand 100cm or less away from the faceplate, the LED was successfully activated.
I began attempting to add the push button to create a silent switch. However, I got confused with this, and received some support via Blackboard from Andrew. Further to this, I also did some research online to find the best solution to having an on/off button.
I managed to create the code which successfully set a value from 1 to 0 if pressed, and then 0 to 1 if pressed later on. In the code, 0 is represented as Silent for the doorbell. 1 being loud.
To create ease, I created two functions to the doorbell ringing. One stardard, activating the buzzer to chime, and the led light emitting. Then another piece of code which flashed only the LED ten times, for when the doorbell was on silent. These two different rings could then be ran by just typing the variable name, rather than repeating code. In this case, they were: 'ringBell' and 'silentBell'.
I then added the buzzer at the end, allowing me to test without the buzzer going off every time during testing.
This is a video of the final code working on the Arduino during testing: