The idea is to create a door alarm system where whenever someone stands in front of the door, the alarm will activate, and the servo motor will move the peephole to open it.
The idea came from Esra, my colleague in the diploma program.
that is what i made ... a door when i be near it the magic eye open and also the buzzer
Electronics Tools
tinker cad
To simulate the circuit and ensure it works with the correct connections.
Crafting Tools
cutter
cardboard
scissors
Electronics Tools
breadboard
adapter 5 volt
arduino uno
jumper wires
ultra sonic sensor
.
https://www.tinkercad.com/things/aZjLGfBB8Ax/editel?returnTo=%2Fdashboard
this is the circuit in tinker CAD in the above link
Design Circuit on Tinkercad:
Circuit Components:
ir sensor
ultra sonic sensor
arduino uno
adapter 5 v
bread board
wires
buzzer
servo motor
Steps Taken:
Connecting the Ultrasonic Sensor (HC-SR04):
VCC from the HC-SR04 sensor to 5V on the Arduino.
GND from the HC-SR04 sensor to GND on the Arduino.
Trig from the HC-SR04 sensor to pin 9 on the Arduino.
Echo from the HC-SR04 sensor to pin 10 on the Arduino.
Connecting the IR Sensor:
VCC from the IR sensor to 5V on the Arduino.
GND from the IR sensor to GND on the Arduino.
OUT from the IR sensor to pin 8 on the Arduino.
Connecting the Servo Motor:
VCC from the servo to 5V on the Arduino.
GND from the servo to GND on the Arduino.
Signal from the servo to pin 11 on the Arduino.
Connecting the Buzzer:
The positive terminal of the buzzer to pin 12 on the Arduino.
Ultrasonic Sensor: Detects the distance between it and a person standing in front of the door. If the distance is less than 30 cm, it activates the alarm.
IR Sensor: Used to detect motion. If motion is detected near the door, the servo is triggered to open the peephole.
Servo Motor: Moves to open the peephole when a person is detected in front of the door and returns to its original position afterward.
Buzzer: Emits a sound when a person is detected in front of the door and motion is detected.
TESTING CIRCUITS
coding
// C++ code
//
#include <Servo.h>
int IR = 8;
int ULTRA = 0;
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
// Sets the trigger pin to HIGH state for 10 microseconds
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
return pulseIn(echoPin, HIGH);
}
Servo servo_11;
void setup()
{
pinMode(8, INPUT);
pinMode(12, OUTPUT);
servo_11.attach(11, 500, 2500);
}
void loop()
{
IR = digitalRead(8);
ULTRA = 0.01723 * readUltrasonicDistance(9, 10);
if (IR >= 1) {
digitalWrite(12, HIGH);
} else {
digitalWrite(12, LOW);
}
if (ULTRA >= 30) {
servo_11.write(180);
} else {
servo_11.write(0);
IR = 0;
}
// ; ( delay(10
{
Build Circuit on Breadbord
I connected the motor and buzzer to the sensors, then completed the rest of the wiring as shown in Tinkercad. Finally, I verified that the circuit works properly.
I made the connection after ensuring that the wiring was correct on Tinkercad. I uploaded the code as text to the Arduino software and ran the circuit.
Making robot
the buzzer didint work and i know that the sensor not good and dont work so i changed it