Description : High Tech Security
The main purpose of this circuit is to detect someone's motion when it comes within the range of the Distance sensor. When this happens, the distance sensor will send the signal to the LED and the buzzer which will get turn on and the motion sensor will start printing "Danger". After this happens, the keypad is used to break the circuit and the when the key on the keypad gets pressed the LED and the Buzzer will turn off and the Motion sensor will start printing reset.
Components Needed
The components that are used to make this security project are -
Making Connections : First Connect the Keypad With the Arduino
The pins that I used to connect the 4x4 keypad with the Arduino are -
- Row 1 - Pin 13
- Row 2 - Pin 12
- Row 3 - Pin 11
- Row 4 - Pin 10
- Column 1 - Pin 9
- Column 2 - Pin 8
- Column 3 - Pin 7
- Column 4 - Pin 6
Making Connections : Secondly, Connect the Buzzer With the Arduino
- Positive - Pin 13
- Negative - Ground Wire (Black Wire )
Making Connections : Then Connect the Motion Sensor With the Arduino
- The motion sensor has three connections and the pins that I used to connect them with the Arduino are -
- Signal - Pin 1
- Power - Power Wire ( Red Wire)
- Ground - Ground Wire ( Black Wire)
Making Connections : After That, Connect the Resistor and the LED With the Arduino
Making Connections : Lastly Connect the Distance Sensor With the Arduino
The distance sensor has four connections and the pins that I used to connect them are -
The Code
Explanation
In function void loop
long duration, distance; digitalWrite(trig, LOW); delayMicroseconds(2); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); duration = pulseIn(echo,HIGH); distance = (duration/74/2);
The code here is for the distance sensor and the formula “distance = (duration/74/2);” is used to determine the distance.
char keypressed = myKey.getKey();
This function is used to give the information to the arduino which key is going to be pressed on the keypad.
if (distance>= 10 && distance <30){ if(digitalRead(pir) ==1){ Serial.println("Danger"); digitalWrite(led,HIGH); buzzer(1); } if(keypressed == '1' ){ digitalWrite(led,LOW); buzzer (0); Serial.println("Reset"); exit; } }
else if (distance>= 30 && distance <70){ Serial.println("No Movement Detected"); digitalWrite(led,LOW); buzzer(0); }
The IF statement is a decision-making statement that is used to inform the program to make decisions based on specified criteria. If someone is within the range of the distance sensor, the buzzer and led will turn on. Else both of these components will be turned off.