Squirt is a motion activated water cannon using Arduino.

This was designed for use in the garden but as it's winter we tested it in the bathroom. It works!

True motion tracking is expensive and complicated so this system activates when the victim moves into range and randomises the position of the cannon and the firing time within a limited area. The sometimes fickle readings from the PIR sensor just adds to the cannon's randomness, and therefore the fun.

This is my first Arduino project.

Step 1: Parts

Windscreen washer pump
PIR motion detector
servo motor
TIP 120 npn transistor
10k resistor
1N4004 diode
12v rechargeable NiMH battery
on/off switch
watertight box to house the workings
Watertight reservoir
Various length 22 awg jumper leads
Soft tubing
Short length of pipe

Step 2: The Circuit

Connect the parts according to the circuit diagram below.
The PIR command wire goes to Digital pin 5 on the arduino and its positive wire goes to 3v pin and ground to ground.
Servo control wire is on pin10.
Pump is on pin 8 via the transistor 9which is protected by the diode).
The battery is a NiMH 12v connected to Vin pin via an on/off switch.

The battery, breadboard and arduino are housed inside a watertight sandwich box.
Mounted on top is the PIR which is inside a length of plastic tube to restrict its field of vision to directly ahead.

The servo is mounted on top of the water reservoir- in this case a plastic tub from the kitchen supplies department of the local supermarket. The pump is fitted near the bottom of the tub with its outlet connected to a flexible pipe from an aquarium supply shop and (rather messily) attached to the sevo arm with a lump of blu-tac.

Step 3: The Code

The arduino code (or "sketch") runs when turned on. Essentially the PIR looks for motion. If it's detected it waits a random length of time between half and 3 seconds, moves the servo arm to a random position 30 degrees either side of center, fires the pump for a half second and returns the servo to center. It then waits for another random length of time and repeats. It fires 3 times then checks the PIR again to see if it detects further motion. See sketch below:

#include <ServoTimer1.h>

  • "Squirt". Jonathan Robson Feb 2009.

int transistorPin = 8; // transistor base connected to pin 8
ServoTimer1 servo1; // defines the servo

long randOff = 0; // Initialise a variable for the OFF time between shots
long randNumber; // Initialise a variable for servo position angle and delay between shots

void setup()
servo1.attach(10); //servo on pin 10
pinMode(8, OUTPUT); // set the transistor pin 8 as output to pump
pinMode(5, INPUT); // set the PIR pin 5 as input
digitalWrite(8, LOW); // defines LOW as movement
randomSeed (analogRead (0)); // randomize


int pinin = 0;
long countint = 0;

void loop()
pinin = digitalRead(5); // reads the PIR sensor
while (pinin == 0)
pinin = digitalRead(5);
servo1.write(90); //sets servo to center
randOff = random (500, 3000); // generate OFF time between 1/2 and 3 seconds
delay(randOff); // waits for a random time while OFF
servo1.write(randNumber = random(60, 120)); // servo to random position within 30 degrees of center
delay(400); //gives servo time to get there
digitalWrite(transistorPin, HIGH); // turns pump on
delay(500); //fires pump for 1/2 second
digitalWrite(transistorPin, LOW); // turns pump off
servo1.write(90); // moves servo back to center

randOff = random (500, 3000); // generate new OFF time between 1/2 and 3 seconds and repeat
servo1.write(randNumber = random(60, 120));
digitalWrite(transistorPin, HIGH);
digitalWrite(transistorPin, LOW);

randOff = random (500, 3000); // generate OFF time between 1/2 and 3 seconds and repeat
servo1.write(randNumber = random(60, 120));
digitalWrite(transistorPin, HIGH);
digitalWrite(transistorPin, LOW);

delay(3000); // gives the PIR time to "settle" before reading again

<p>Sadly the original diagram is long lost and the Arduino recycled into other projects, but if you Google the problem you will find several circuit diagrams with the same solution of how you control a 12v DC motor with an Arduino. Here's a nice clear picture of somebody else's solution that uses the same circuit as mine. Just ignore the 5v rail on this diagram and replace it with the PIR and servo. I like this because it uses a 12v socket to a wall-wart rather than a battery you have to keep recharging. Yes, it uses an Arduino Mini but the pins it uses are on all other Arduino boards too.</p><p>Step 2 of Squirt Instructable tells you where to put the servo and PIR control leads - the others are just live and ground.</p>
cool Dude !!!!!
Great projetc :) the picture of the circuit is unreadable halas :( <br>could you please send a bigger one ? <br>thanks
There would be a market to sell something like this. The ones you buy in the shops (i.e. scarecrow) have to be hooked up to a hose outdoor water supply. If you don't have a outdoor hose this is a great option... If someone in the UK makes one I would buy it.
hey guy....awesome job....but could you take a better picture of the circuit..? i can&acute;t see it exactly...thankss so much
lol Awesome and please the circute<br />
Can you post a better pic of the circuit?&nbsp; This will be my first and I'm doing it to scare the deer away from my flowers.&nbsp; I will be making some modifications, but I'll post here when done.<br />
seriously ... this is incredible ... looks like i gotta get me the materials and start building my twist on this project ... thank you SO&nbsp;much <br /> <br /> know anything about bioSensors? <br />
Put it on the lawn - <em>cats beware!</em><br/><br/><sub><sup>There's got to be <em>something</em> that will stop them &quot;going&quot; on my lawn...</sup></sub><br/>
Sprinklers anyone? XD
I saw a video somewhere online of a DIY device that fired a flashgun, sprayed water and possibly had some kind of noisemaker component when triggered by a motion sensor (on the kitchen counter to scare away cats).<br/><br/>The <a rel="nofollow" href="http://www.youtube.com/watch?v=wlCzIr-_0GI">ssscat</a> is a commercial solution that sprays compressed air out on detecting motion- it's a neat idea but I'm not sure about commercial compressed air- it seems to contain an unpleasant proportion of VOCs (hence schoolmates getting high huffing upside-down air dusters from the camera shop &gt;_&lt;). <br/><br/>For the ultimate solution there's always the <a rel="nofollow" href="http://www.youtube.com/watch?v=ybaPJ51u1sI">quintessential sentry gun</a>- I'm sure you could replace the BB gun with a water jet. I still love the end of that video seen from the sentry's point of view, it's like every motion-tracking camera in sci-fi ever.<br/>
i'd really like to see a stripped-down version of this (no arduino) for use as an automatic water dispenser. is this possible?
The PIR I got at Halted has an analog out, I think the voltage is proportional to the measured distance. Or you could get a pair of ultrasonic detectors. Then with a bit of trigonometry you could center the spray on the motion!
Is that a Windscreen washer pump ? I have two lying around and Might use one of these .
That is awesome! Just what I was looking for.
I love it!!!
You should make the title more descriptive like "Squirt: A motion activated water cannon using an Arduino.

About This Instructable




Bio: Science museum exhibit design and fabrication manager, stagehand, ballet shoe maker, theatre production manager, project manager and art director of the Beijing Aquarium rainforest exhibit ... More »
More by Jonathan Robson:Arduino Nerf Target Practice Arduino Personal Soundtrack Hoodie Arduino / Wii controlled Lego Star Wars rocket turret 
Add instructable to: