Introduction: Automated Arduino Tap

About: I'm a high school student that thinks that school doesn't teach cool enough things. I'm trying to find my way in this world by exploring it. Instructables is a fantastic place to do that.

This project was designed for my dog, who refuses to drink from a water bowl. She often sits by the tap for hours waiting for someone to pass and open it for her. So I built her this automatic tap that opens when it senses her and closes again when she's out of range.

The whole setup is centered around a 20L bucket. This allows it to stand even where there is no tap. It uses a Arduino Nano as a controller, a normally closed solenoid valve as a tap and a 12V battery as a power supply.

I created this tap as a solution to a problem that, while most people probably never experience it, was quite a problem to my family. Trust me, there is nothing sadder than a dog sitting for probably half an hour waiting for someone to see her and open the tap. And then to stand there and wait for her to finish before you can go about your business can also be a nuisance.


12V solenoid valve
Arduino nano
HC-SR04 range sensor
10K resistor
MOFSET (I used a IRFZ24N)
12V battery
Jumper cables
Female spade terminals for the battery and solenoid valve
A bucket
About a meter of twin flex
Epoxy glue
Some plumbing pieces the same diameter as your solenoid. I used 2 elbow joints and 2 connector pieces
A strip of flexible metal
Some rivets
Two small plastic containers to protect your components from the elements

Step 1: Connecting the Circuit

Connect everything together as shown in the schematic above and mount it onto a mini breadboard.
The DC motor in the schematic represents the solenoid.
The reason for the MOFSET is that the Arduino can't drive the 12V solenoid by itself. The Arduino's output is only 5V therefore the MOFSET allows the Adruino to still control the solenoid while the battery powers it. The battery also powers the board through the VIN pin.
It isn't recommended to omit the diode. The solenoid opens and closes by means of an electromagnet. The closing magnetic field can induce a backward flowing current that damages the board.

Step 2: The Code

int trigPin = 12;
int echoPin = 11;
int valvePin = 9;
long distance;
long duration;
void setup(){
  pinMode (9, OUTPUT);
  pinMode (trigPin, OUTPUT);
  pinMode (echoPin, INPUT);
void loop() {
  if(distance <= 25){
  digitalWrite (9, HIGH);
    Serial.print("Distance: ");
  else {
    digitalWrite (9, LOW);
void ultra(){ //the range sensor's code
  digitalWrite(trigPin, LOW);
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;

Step 3: The Bucket: Part 1

Drill a hole the diameter of your solenoid as close to the bottom of the bucket as possible.
Screw the pieces together as shown, then screw the elbow piece into the rest through the hole.

Step 4: The Bucket: Part 2

First, mark and drill holes for the range sensor into its container (the sensor box). Drill another hole on the top for the wires to come out.

Next, cut a strip of metal and rivet it onto the top of the bucket. On the other end, rivet the container.

Put the sensor inside. Pull the wires through the holes and connect them.

Step 5: Assembly: Part 1

Drill holes on the sides of the other container (control box). Place the breadboard inside and string the wires through the holes.

Manipulate any components so that they fit into the box.

Step 6: Assembly: Part 2

Attach the solenoid's spade terminals to one end of two male-to-male jumper wires. Run the male ends through the control box's hole.

Wire the positive terminal of the battery to the VIN pin and the negative to the ground pin.

Step 7: Assembly: Part 3

Use the epoxy to glue the control box and the wires to the bucket.

Tidy up any other loose ends and you're done!

Step 8: Testing Your Creation

Finally, test your creation. Put the bucket on a stool or step or something, connect the battery and make sure everything works.

Step 9: Teaching the Dog

Possibly the hardest step of all if your dog doesn't already drink from a tap. Luckily mine does and she quickly realised that she doesn't have to wait for anyone to open this tap. The video is of her on her first go. She took to it like a fish to water. This is proof that you really can teach an old dog new tricks.

Well that's it. I hope you, and your dog, enjoyed this instructable.

Battery Powered Contest

Runner Up in the
Battery Powered Contest