Rucksikaa Raajkumar
Published © CC BY

Automatic Faucet (Touchless) Using Arduino for COVID-19

You do not have to touch the surface of the faucet after you wash your hands. Wash hands safely and prevent coronavirus disease.

IntermediateFull instructions provided1 hour9,150

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Relay Module (Generic)
×1
Submersible water pump - 5V
×1
Jumper wires (generic)
Jumper wires (generic)
×9

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Code

Automatic Faucet (Touchless) using Arduino

Arduino
// 66. AUTOMATIC FAUCET(TOUCHLESS) USING ARDUINO
// ARDUINO PROJECTS BY R
// AUTHOR: RUCKSIKAA RAAJKUMAR
#define trig 5
#define echo 4
const int Relay = 6;
long duration;
int distance;
void setup() {
  pinMode(trig, OUTPUT); // Set the trigger pin as OUTPUT
  pinMode(echo, INPUT); // Set the echo pin as INPUT
  pinMode(Relay, OUTPUT); // Configure the pin of the relay module as OUTPUT
  Serial.begin(9600); // Set baud rate as 9600
}
void loop() {
  digitalWrite(trig, LOW);
  delayMicroseconds(5);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH); // Calculate time taken (in microseconds) for the pulse emitted by the trigger pin to reach the echo pin.
  distance = (duration/2) * (331.3/10000); // Calculate the distance from the sensor to the obstacle in cm, using the speed of sound in air(m/s) and the time taken (stored in duration variable)
  Serial.println(distance);
  if(distance>1 && distance<10){ 
    digitalWrite(Relay, HIGH); //Turns on the submersible water pump or solenoid water valve
  }else{
    digitalWrite(Relay, LOW); //Turns off the submersible water pump or solenoid water valve
   }
   delay(2000); // Set a delay period of 2 seconds to prevent the clicking of the relay module
}

Credits

Rucksikaa Raajkumar

Rucksikaa Raajkumar

41 projects • 90 followers
Amateur Arduino Developer. Undergraduate. YouTuber (https://www.youtube.com/c/RucksikaaRaajkumar/videos) and Blogger (Arduino Projects by R)

Comments