Robot That Automatically Fills Up the Dogs Water

by jennaloss79 in Circuits > Arduino

40 Views, 1 Favorites, 0 Comments

Robot That Automatically Fills Up the Dogs Water

IMG_9508 (1).jpg

A dog is a man's best friend. But the question is, "what is a dog's best friend?" Meet Squirtle: the robot that automatically fills up the dogs water. You should watch the video down bellow so you can see the robot in action.

Supplies

IMG_8891.jpg
IMG_8917.jpg
Image 5-12-25 at 3.35 PM.jpeg

So, in order to build this you need the Super Learning Kit from LavfinTech.com, this miniature water pump and a 1 gallon water jug. You can find all of these on Amazon.

Add the Arduino

IMG_8902.jpg
IMG_8905.jpg

First, you are going to pull your Arduino and your bread board. Then you are going to hook up a male to male wire to the 5 volt port and a male to male wire to the ground port on the Arduino with male to male wires. Then plug the 5 volt and the ground into the positive and ground on the breadboard.

Add the Servo and Water Level Sensor

IMG_8906.jpg

Next, pull out the servo and the water level sensor. On the water sensor attach male to female jumper wires. Then, on the servo attach male to male wires.You are then going to hook up the negatives and positives from the servo and the water level sensor anywhere on the negative and positive ports on the breadboard.

Finish the Servo

IMG_8907.jpg

Then plug in a male to male wire to port 9 on the Arduino and plug that in anywhere on the breadboard that is not in the negative or positive columns. After that, plug in the leftover wire from the servo (the yellow one) to the direct right of the other wire from port 9.

Finish the Water Level Sensor

IMG_8908.jpg

Then you are going to take a male to male wire and attach it to the A0 port on the Arduino. Put the wire anywhere on the breadboard that is not in the negative or positive columns. Then attach the leftover wire on the water level sensor to the direct right of this wire.

Power

IMG_8909.jpg

If you want you can make it battery-powered by plugging the Arduino into this circuit and plugging a 9-volt into that. But I recommend just using an outlet.

Add the Code

IMG_8910.jpg
IMG_8911.jpg

I have pictures of the code here but here it is so you can just copy and paste it.

#include <Servo.h> // Make sure to include the Servo library


Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position

int adc_id = 0; // ADC pin to read from

int HistoryValue = 0; // Variable to store the last ADC value

char printBuffer[128]; // Buffer for printing

bool hasMoved = false; // Flag to check if the servo has moved


void setup() {

myservo.attach(9); // attaches the servo on pin 9 to the servo object

Serial.begin(9600); // Start serial communication at 9600 baud

}


void loop() {

// ADC reading logic

int value = analogRead(adc_id); // get ADC value


// Check if the historical value has changed significantly

if (((HistoryValue >= value) && ((HistoryValue - value) > 10)) ||

((HistoryValue < value) && ((value - HistoryValue) > 10))) {

sprintf(printBuffer, "ADC%d level is %d\n", adc_id, value);

Serial.print(printBuffer);

HistoryValue = value; // Update the history value

}


// Start the servo motor if the historical value goes below 250

if (HistoryValue < 250 && !hasMoved) {

for (pos = 0; pos <= 130; pos += 1) {

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

for (pos = 130; pos >= 0; pos -= 1) {

myservo.write(pos); // tell servo to go back to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

hasMoved = true; // Set the flag to true to prevent repeated movement

}


// Reset the flag and move the servo again if the historical value goes above 249

if (HistoryValue > 249 && hasMoved) {

for (pos = 0; pos <= 130; pos += 1) {

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

for (pos = 130; pos >= 0; pos -= 1) {

myservo.write(pos); // tell servo to go back to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

hasMoved = false; // Reset the flag to allow movement again

}

}

Now in order to download it you have to have an Arduino I.D.E. I'm not going to walk you through how to download it because there are hundreds of you tube videos about it and it is a bit different for each computer. Oh and make sure the code starts from the second line or else it won't run. Then you can download the code to the Arduino.

Attaching the Servo

IMG_8916.jpg

At this point, you are going to hot glue the servo to the corner where it can press the button on the water pump. Before you hot glue it you need to make sure it is facing the right direction. When you give power to the Arduino, the servo motor should move unless the water level sensor is in water. The other thing that you need to do is to take the stickers off the servo before you hot glue it.

Finish the Wiring

IMG_8918.jpg

Then you need to add more male to female wires to the water level sensor to make it longer because this needs to go in the dog bowl.

Hot Glue

IMG_8914.jpg
IMG_8913.jpg
IMG_8912.jpg
IMG_8915.jpg

You need to add hot glue to the front and back of the water level sensors. You need to make sure no hot glue gets on the copper strips because then the water level sensor won't work. Then hot glue all of the wire connections including the bread board and the Arduino. That way they won't come off.

Pump Meet Water Jug

IMG_9509.jpg

Then, using hot glue, attach the water pump to the lid of the water jug.

Put It All Together

IMG_9510.jpg

Next, hot glue a piece of cardboard onto the water jug. Following that, use the peel and stick on the breadboard to stick it to the cardboard. Then hot glue the Arduino to the side of the water jug.

Customization

IMG_9508.jpg

The next step and the most important step is to add on some googly eyes and you're good to go.

Finish

Lastly, you need to hot glue the water level sensor to the top of your water dish. You will need to scratch up the spot you hot glue the sensor on and make sure the sensor is dry.