Last Updated on May 19, 2022 by technoreview85
In this article, I will describe how you can make an automatic water tap machine or an automatic hand washing machine using Arduino UNO.
You need to make
- Arduino UNO
- Single-channel relay module
- HC-sr04 Ultrasonic sensor
- Mini DC pump
- Pipe
- PVC pipe 20mm( dia)
- Jumper wire
- 2x 9v battery or power bank or DC 9v power supply
- Tub
- Plywood
- LED (Blue)
- 220-ohm resistor
Connection
- Ultrasonic module HC-sr04 Trig pin connect to Arduino Digital pin – 2
- Ultrasonic module HC-sr04 Echo pin connect to Arduino Digital pin -3
- Relay module signal in pin connect to Arduino Digital pin – 8
- LED connect to pump (+) & (-) via 220 ohm resistor
Here I used two 9 v batteries, one for Arduino & another for pump & relay.
Arduino Code
//Ultasonic Sensor //Pins connected to the ultrasonic sensor #define trigPin 2 #define echoPin 3 //LED pins #define led 9 #define pump 8 int range = 5;//range in inches void setup() { // initialize serial communication: Serial.begin(9600); //initialize the sensor pins pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); //initialize LED pins pinMode(led, OUTPUT); pinMode(pump, OUTPUT); //set LEDs digitalWrite(led, HIGH); digitalWrite(pump, LOW); } void loop() { // establish variables for duration of the ping, // and the distance result in inches and centimeters: long duration, inches, cm; // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(5); digitalWrite(trigPin, LOW); // Take reading on echo pin duration = pulseIn(echoPin, HIGH); // convert the time into a distance inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); if(inches < 5) { Serial.println("hand puted"); digitalWrite(led, LOW); digitalWrite(pump, HIGH); delay(100); } else { Serial.println("no hand"); digitalWrite(led, HIGH); digitalWrite(pump, LOW); delay(100); } delay(200); } long microsecondsToInches(long microseconds) { return microseconds / 74 / 2; } long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }
You can copy the above code or you can download the code bellow
You can download the code from here
Thanks for share this article it’s quite helpful to me.
Best regards,
Mead Duke
Hey there! I’ve been reading your website for a long time now and
finally got the courage to go ahead and give
you a shout out from Atascocita Texas! Just wanted to mention keep up the excellent job!
Thanks very nice blog!
Nice post. I was checking constantly this blog and I am inspired!
Extremely helpful information specially the ultimate phase 🙂 I maintain such info a lot.
I used to be seeking this certain information for a very
long time. Thank you and good luck.
Right here is the right blog for everyone who would like to
find out about this topic. You understand a whole lot its almost tough to argue
with you (not that I really will need to…HaHa).
You definitely put a brand new spin on a topic which
has been written about for a long time. Great stuff, just excellent!
Thanks for a marvelous posting! I certainly enjoyed reading it,
you could be a great author. I will make certain to bookmark your
blog and definitely will come back someday. I want
to encourage one to continue your great posts, have a nice weekend!
I could not resist commenting. Perfectly written!
Way cool! Some extremely valid points! I appreciate you writing this article and the rest of the site is really good.
I was recommended this website by my cousin. I am not sure whether this
post is written by him as no one else know such detailed
about my problem. You’re amazing! Thanks!
Hey very interesting blog!
Hello! I could have sworn I’ve been to this site before but after looking at a few of the posts Irealized it’s new to me. Anyways, I’m definitely happy I came across it and I’ll bebook-marking it and checking back regularly!
What happens when i put n ac pump behalf of mini dc pump
You can use AC pump with it but needed to add some minor changes
Very wonderful info can be found on web blog.
thanks.For your help!
Nice post. I used to be checking continuously this weblog and I’m impressed!
Very helpful information specially the ultimate section 🙂 I
handle such information much. I was seeking this certain information for a very long time.
Thank you and good luck.
do you have the circuit diagram for this?
I gotta bookmark this internet site it seems extremely helpful very beneficial
Hy! Your project is awesome but in my relay module I have not 2 GND together what should I do?
Gnd is common so you can connect any gnd
How to use the code to circuit board
please search for uploading code to Arduino UNO
Is anyone having a problem with arduino code ? Just to know before trying it
I need to add solenoid valve in the place of dc pump , can you explain how