dikshadwivedi1819
Published © GPL3+

Contactless Doorbell

Transform your doorbell, in these covid times!!!!

IntermediateShowcase (no instructions)83
Contactless Doorbell

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1
Switch Actuator, Head for spring return push-button
Switch Actuator, Head for spring return push-button
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Schematics

Circuit Diagram

Code

Contactless Doorbell

C/C++
#include <Servo.h>  
#define trigPin 3  
#define echoPin 2  
Servo servo;  
// int sound = 250; 
int pos = 0;  
int led = 5;
void setup() {  
Serial.begin (9600);  
pinMode(led, OUTPUT);
pinMode(trigPin, OUTPUT);  
pinMode(echoPin, INPUT);  
servo.attach(4);  
}  
void loop() {  
long duration, distance; 
 
digitalWrite(trigPin, LOW);  
delayMicroseconds(2);  
digitalWrite(trigPin, HIGH);  
delayMicroseconds(10);  
digitalWrite(trigPin, LOW);  
duration = pulseIn(echoPin, HIGH);  
distance = (duration/2) / 29.1;  
if (distance < 10) {  
Serial.println("the distance is less than 10");  
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    servo.write(pos);  
    digitalWrite(led, HIGH);// tell servo to go to position in variable 'pos'
    delay(5
    );                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    servo.write(pos); 
    digitalWrite(led, LOW);// tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
  } 
}  
else {  
servo.write(0);  
}  
if (distance > 60 || distance <= 0){  
Serial.println("The distance is more than 60");  
}  
else {  
Serial.print(distance);  
Serial.println(" cm");  
}  
delay(500);  
}     

Credits

dikshadwivedi1819

dikshadwivedi1819

5 projects • 2 followers

Comments

Add projectSign up / Login