DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

Arduino + Ultrasonic sensors for Automatic Tap Control

About this project:

When talking about proper water management, we humans underestimate some of the following facts:

  • Running the tap while brushing your teeth can waste 4 gallons of water.
  • Leaky faucets that drip at the rate of one drop per second can waste up to 2,700 gallons of water each year.
  • Showering and bathing are the largest indoor uses (27%) of water domestically.
  • About 95% of the water entering our homes goes down the drain.






Our idea is to apply a proper water management technique in our homes.  We are targeting to save water from leaky and running taps by automating our domestic tap.

Here’s how it works:

The set-up is shown below. Whenever it detects someone placing hand beneath the tap, it commands the servo motor to turn-on the tap and keep a check on. When the user removes the hand, the tap would be turned off instantly. This would ensure that tap runs only when needed, conserving the precious water.



The average faucet flows at a rate of two gallons per minute; by simply turning the tap off, we can save more than 100 gallons of water per person each month. While brushing or washing hands an average person who keeps the water running, will spend for about 1.875 gallons of water a day and 684 gallons of water a year; by using this idea one can save this much amount of water which can further be used for the betterment of society and substantially decreasing water scarcity problems.



  1. Arduino Uno (R3)
  2. Servo motor  (SM-S2309S)
  3. Ultrasonic Sensor (HC-SR04)
  4. 16X2 LCD
  5. Zero-PCB
  6. Solder + Soldering Iron

Circuit connections:

  • Servo motor’s signal pin connected to Arduino pin ~9.
  • Echo pin and Trigger pin of Ultrasonic sensor are connected to Arduino pin 12 and ~11 respectively.
  • LCD connections are as follows:

LCD pin

Arduino pin

















  • All VCC and GND pins of respective components are connected to VCC and GND pins of Arduino UNO.

Some Soldering skills required: For this project I created my own shield so that I could simply plug ‘n’ play all the required components. Here’s how to make your own;

  1. Take a good quality Zero PCB (I generally prefer UNIVOLT’s )
  2. Cut it into required size so that it fits onto your Arduino board.
  3. Now place your components on this piece to verify arrangement.
  4. Now solder male berg-strips accordingly.
  5. Make connections as told earlier.
  6. Insert your custom shield into Arduino and plug all the components onto it. 


Installation at wash-basin:

  • Attach a suitable horn onto the servo, as shown in video.
  • Connect this horn with the thread which wraps around the tap’s turning head.
  • Place and fix the servo at a certain distance from the tap so that perfect amount of torque could be generated. I used M-seal to do so.
  • Now place ultrasonic sensor just beneath the tap ensuring that water doesn’t affect it and it should be able to take proper readings as well.
  • Plug in the LCD.
  • Burn the Code and enjoy your own Automated Tap.
  • Refer video for a better idea.


Code discussion:

  • The code make use of three libraries : , and LiquidCrystal.h>; out of these three, has to be imported externally. This library can be found attached with the folder.
  • The value of distance required to trigger the servo motor into action varies with the surroundings. So please make sure that you first calibrate your ultrasonic for the same.
  • Also the servo turning angle may vary according to tap used. So make sure you repeat the calibration in this step as well.  
  • I have also coded to serially print the distance each time ultrasonic updates itself. This can be omitted.
  • I have made use of a variable “allow” which ensures same conditional statements are not executed consecutively. This adds in the smooth functioning of this project.  









GANEEV SINGH is a B.Tech. final year student studying Electronics and Communication, from IP University Delhi with area of interest lies in Electronics, Embedded Systems, Robotics and Automation. And moving further into current Bachelor’s domain and pursue Master’s in the related field. Currently contributing engineering projects with RS Components & Controls (I) Ltd. to be published on

RS-India-Guest-Blogger has not written a bio yet…

25 Jul 2016, 6:53



May 16, 2017 12:48

Far easier to just use a solenoid valve in-line and you don't have to stick anything to your sink!

0 Votes