bksdacosta
Published

An Automated Pool-Side Water Gun for Dogs

Tucker out your water obsessed dog with this random direction dog sprayer.

IntermediateFull instructions provided173
An Automated Pool-Side Water Gun for Dogs

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
Any Arduino will work, you just need 1 pin to control a servo.
×1
Servo Motor Waterproof
×1
Water Pump
I use a fountain pump that can pump 280 gph.
×1
Plastic tube 1mm, (1-2m)
Tubing for the water pump.
×1
Tube Nozzle
I 3d printed a nozzle, but one could also be bought or made with tape.
×1
Tube Slant
I 3d printed a thing to attach the water tube to the servo motor using zip ties and slant the tube upwards. I think this attachment could be made in many ways using a combo of zip ties, wood, and/or plastic.
×1
Table or Plank of Wood
I used a plastic table I bought for 8 dollars to mount the components on. You could also just use a plank of wood and put it under a chair.
×1
Mount for Servo
I 3d printed a servo mount but it could also be made of wood, plastics, screws, or zip ties.
×1
Accessory, Screw
Accessory, Screw
×1
Zip ties
Zip ties are Just generally helpful to attaching objects together.
×1
2-way Extension Cord
The device can be easily turned on and off by plugging in this extension cord.
×1
Arduino Case
It's not required, but its nice to put your Arduino in a case.
×1
USB Charger for Arduino
×1

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Custom parts and enclosures

Cad Directory

These parts can be made in other ways (wood, zip ties, etc) , but it is nice to 3d print them.

Schematics

Standard Servo Hookup

Code

Random Servo Direction Code

Arduino
#include <Servo.h>
Servo myservo;  // create servo object to control a servo


/*
 * This code controls a servo that is attached to a tube straying out water. The servo
 * is meant to direct the water stray randomly between a minAngle and maxangle.  Once the 
 * servo moves to its random position, it will wait a random amount of time before moving again.  
 * 
 * By randomly changing the direction of the water and waiting, the dog is kept entertained because she/he is 
 * unable to guess what the water will do next. 
 */
int minAngle = 50;    // The mimimum angle of the servo
int maxAngle = 160;   // The maximum angle of the servo
int pos = 0;          // The variable to store the current servo position
int newPos;           // The variable to store the new servo position

int minDelayStep = 10;  //The mimimum wait time between each "step" of the servo (smaller wait time -> faster movement)
int maxDelayStep = 100; //The maximum wait time between each "step" of the servo (larger wait time -> slower movement)
int delayStep;          // The variable to store wait time between each "step" of the servo

int minWaitTime = 500;  //The mimimum wait time after the servo has stopped moving
int maxWaitTime = 2500;  //The maximum wait time after the servo has stopped moving

void setup() {
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  randomSeed(analogRead(0));
}


/* Before running the random code, you might want to test the servo's back and forth
 *  action. To do this, uncomment the definition below
 */
//#define BackAndForthTest
#ifdef BackAndForthTest
  void loop() { //Test the servo's ability to go back and forth 
    for (pos = minAngle; pos <= maxAngle; pos += 1) { 
      // in steps of 1 degree
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits for the servo to reach the position
    }
    delay(1500);  //Wait a bit to indicate the servo has reached its maximum angle
    for (pos = maxAngle; pos >= minAngle; pos -= 1) {
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits for the servo to reach the position
    }
    delay(1500);  //Wait a bit to indicate the servo has reached its maximum angle
  }
#else
  void loop() { //Random loop
      newPos = random(minAngle, maxAngle); //Randomly pick a direction to aim
      delayStep = random(minDelayStep, maxDelayStep); //Randomly pick the speed to move to that new direction
      if (pos <= newPos){  // Check if the new postion is going up or down compared to the old position
        for (pos; pos <= newPos; pos += 1) {
          myservo.write(pos);              // tell servo to go to position in variable 'pos'
          delay(delayStep); 

          /*
          Serial.print("posUp:");
          Serial.print(pos);
          Serial.print("  newPos:");
          Serial.print(newPos);
          Serial.print("  delay:");
          Serial.print(delayStep);
          Serial.print("\n");
          */
        }
      } else {
          for (pos; pos >= newPos; pos -= 1) {
            myservo.write(pos);              // tell servo to go to position in variable 'pos'
            delay(delayStep); 
            
            /*
            Serial.print("posDown:");   
            Serial.print(pos);
            Serial.print("  newPos:");
            Serial.print(newPos);
            Serial.print("  delay:");
            Serial.print(delayStep);
            Serial.print("\n");
            */
          }
      }
      delay(random(minWaitTime, maxWaitTime)); //Wait a random amount of time
  }
#endif

Credits

bksdacosta
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.