Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
GadhaGod
Published

Touchless Doorbell

No more spreading germs through doorbells.

BeginnerShowcase (no instructions)10,596
Touchless Doorbell

Things used in this project

Story

Read more

Code

Doorbell

C/C++
/*
'DISTANCE SENSOR:
Vcc goes to 5V on arduino
Gnd goes to ground pin on arduino.
Trigger goes to pin 8 on the arduino.
Echo goes to pin 9 on the arduino.

BUZZER:
Positive leg goes to pin 12 on the arduino.
Negative leg goes to GND on arduino.
*/
int trigPin = 8;    
int echoPin = 9;    

 
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  delay(100);
}
 
void loop() {
 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  int duration = pulseIn(echoPin, HIGH);
  delay(50);
  
  if (duration <= 600){
    tone(12, 2000, 3000);
  }

  else{
    noTone(12);
    
  }
}

Credits

GadhaGod
17 projects • 20 followers
Contact

Comments

Please log in or sign up to comment.