Search This Blog

Copyright - Technoreview85. Powered by Blogger.

How to make an AC power outlet timer using IC555

This is a complete step-by-step guide to making an electric timer plug. This timer Ac socket can turn on or off any Ac electrical appliance....

Back to Top

Recent Posts

Friday, February 28, 2020

How to make an automatic water tap machine using Arduino

  Avik Roy       Friday, February 28, 2020

automatic water tap

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.


Connection diagram of automatic water tap

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

Video tutorial of Automatic water tap



logoblog

Thanks for reading How to make an automatic water tap machine using Arduino

Previous
« Prev Post

No comments:

Post a Comment