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

Make Touchless ANY THING using ultrasonic sensor module

In this condition of COVid-19, we should avoid touching like Doorbell or anything so in this project to make anything Touchless/NON-contact

BeginnerFull instructions provided6,532
Make Touchless ANY THING using ultrasonic sensor module

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Relay (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Schematics of this projects

Schematics of relay module

Code

CODE:

C/C++
//this project is made by Circuit Mania  
//https://www.youtube.com/channel/UCJPKa558LvFFYOL3zfEmJ9g?view_as=subscriber
const int pingPin = 7;
//adjust this to set the min speed of wave gesture
const int waveBackWait = 5000;
//Range of detection from the sensor in cm
const int range = 7;
void setup() {
  pinMode(10, OUTPUT);
}
void loop() {
  long duration, cm;
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  
  cm = microsecondsToCentimeters(duration);
if(cm < range && cm > 1){
    for(int i=waveBackWait; i>0; i--){
      long new_duration, new_cm;
      pinMode(pingPin, OUTPUT);
      digitalWrite(pingPin, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin, LOW);
      pinMode(pingPin, INPUT);
      new_duration = pulseIn(pingPin, HIGH);
  
      new_cm = microsecondsToCentimeters(new_duration);
      if(new_cm < range && new_cm > 1){
        //ring the doorbell
        digitalWrite(10,HIGH);
        delay(500);
        digitalWrite(10,LOW);
      }
    }
  }
}
long microsecondsToCentimeters(long microseconds) {
  return microseconds / 29 / 2;
}

Credits

BEASTIDREES62
4 projects • 30 followers
Contact

Comments

Please log in or sign up to comment.