logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

Keep cats at bay with an auto-trigger water spray and the power of an Arduino Uno

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at May 17, 2021
Categories
  • Arduino
Tags
Keep cats at bay with an auto-trigger water spray and the power of an Arduino Uno

If you want to keep the cats off the counter, a squirt bottle is an easy discipline method. However, you can’t always be in the room. If you want to keep them off the counter even when you’re not around, you can build your own motion-activated squirt bottle using a few off-the-shelf parts.

How the Squirt Bottle Works

Squirt bottles use a simple lever to pump water from a base into a nozzle that sprays water outward. That simple mechanism makes it relatively easy to control with a small motor or servo. It’s so easy, in fact, that Raid even made an auto trigger squirt bottle with a small battery.

For this project, we’ll be disassembling this specific model of Raid bottle, but the same equipment and principles can be applied to any squirt bottle. Some may find it easier to use a servo with a string wrapped around the trigger, others can connect a motor directly to the nozzle’s mechanics.

Inside the Raid bottle, you’ll find a red and white wire connected to a battery compartment. You can start by clipping these wires, stripping the ends and, for convenience, extending them with some extra wiring and some solder. Be sure to use heat shrink to cover the connections you’ve just made. If you’d rather not use this method (or if you can’t get your hands on this Raid squirt bottle), keep reading and by the end you’ll at least know enough to start rigging up your own squirt bottles.

What You’ll Need

Since this project can be done a variety of ways, we’ll break the parts list into two sections. The first list includes everything you’ll need, regardless of what bottle you end up using:

Arduino Uno Arduino Uno
A diode diode
NPN transistor NPN transistor
A breadboard breadboard
A PIR motion sensor

(I’m using an XC-4444)

PIR motion sensor
Arduino IDE Arduino IDE

Next, the following list includes materials you’ll need for the Raid-specific variation. This setup can be a bit cleaner in the final product, but since the bottle is uncommon, you may need to adapt this guide to your needs.

Raid Max Auto Trigger Bottle

 

(Our guide is designed for the Raid variety, but you can adapt an auto-trigger bottle as long as it’s similar!)

Raid Max Auto Trigger Bottle
Heat shrink Heat shrink

As mentioned above, disassemble the top of the Raid bottle, remove the battery compartment, and solder some extra wire to the ends of the red and white wires connected to the motor. This will make it easier to complete the rest of the wiring.

You’ll also need a few more generic pieces, such as extra wiring, a USB cable, and a soldering iron.

The Code

If you followed our guide on how to use the PIR proximity sensor, the code here should look pretty familiar, but with a couple small tweaks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const int motionPower = 13;
const int motionIn = 12;
int motor = 3;
 
void setup(){
  pinMode(motionPower, OUTPUT);
  pinMode(motionIn, INPUT);
  pinMode(motor, OUTPUT);
  digitalWrite(motor, LOW);
  digitalWrite(motionPower, HIGH);
  Serial.begin(9600);
}
 
void loop(){
 
  int value= digitalRead(motionIn);
  if (value == HIGH){
  digitalWrite(motor, HIGH);
  Serial.println("Squirt activated.");
  delay(500);
  digitalWrite(motor, LOW);
  delay(5000);
}
}

We won’t repeat the explanation here too much (and there’s more to explain with the wiring later on), but there are a few pieces that are important to understand.

1
2
3
const int motionPower = 13;
const int motionIn = 12;
int motor = 3;

In the previous PIR tutorial, we wired the sensor a bit differently. For convenience, this time we’ll plug it directly into the Arduino itself. Some versions of the sensor have the pins reversed but for the one we’re using, the left-most pin is ground, the middle is power, and the right is signal. So, we’ll plug it directly into pins 12, 13, and GND.

With this code block, we’ll assign the latter two pins to variables. Pin 12 will go to the input from the sensor, and pin 13 will be assigned to power. Be sure to check to make sure this is the correct arrangement for your sensor as well.

1
2
3
4
5
6
7
8
void setup(){
  pinMode(motionPower, OUTPUT);
  pinMode(motionIn, INPUT);
  pinMode(motor, OUTPUT);
  digitalWrite(motor, LOW);
  digitalWrite(motionPower, HIGH);
  Serial.begin(9600);
}

In the setup() section, we’ll assign the variables motionPower and motor to outputs, which will allow the Arduino to send power to these pins. The variable motionIn will be assigned an input so it can send a signal to the Arduino when it detects motion. Finally, we’ll write motionPower to LOW which will turn the motor off to start with and set the motionPower pin to HIGH, then send power to it.

1
2
3
4
5
6
7
8
  int value= digitalRead(motionIn);
  if (value == HIGH){
   digitalWrite(motor, HIGH);
   Serial.println("Squirt activated.");
   delay(500);
   digitalWrite(motor, LOW);
   delay(5000);
  }

Finally, inside the loop() section, this code will read the status of the motion sensor. If it detects motion, the if statement will start. This block will turn on the motor for 500 milliseconds before turning it off again. You can adjust this if you need it to spray more or less water when it’s triggered. It will also print “Squirt activated.” to the serial monitor to help with troubleshooting.

The final delay() statement will pause the script for 5 seconds before continuing. This will prevent the sensor from getting triggered too many times in a row. You can also adjust this delay to your liking.

The Wiring

The wiring on this project is a little more complex than the previous motion sensor guide. The motor in the Raid bottle requires more energy than the Arduino is capable of outputting on a single pin. To solve this problem, we’re going to add a transistor and a diode. This will make the wiring a bit more complex, so we’ll take it in stages. First:

  • Add the NPN transistor to your breadboard with the curved side facing away.
  • Connect the leftmost pin on the flat side to GND.
  • Connect the middle pin of the transistor to pin 3 on the Arduino.
  • Connect rightmost pin to the red power cable coming from the motor in the Raid bottle.

Next, we’ll add the diode. Diodes only allow electrons to flow in one direction. This will help prevent any excess power running to the motor when it shuts off from flowing back through the circuit.

  • Connect the end of the diode without the gray stripe to the same row on the breadboard with the third transistor sensor and the power pin leading to the motor.
  • From the other end of the diode, the end with the gray stripe, connect one wire to the 5V pin on the Arduino.
  • Connect this same row to the ground cable coming from the motor.

Once the code is uploaded and this wiring is set up, your automatic water bottle will be nearly set up. Depending on the power requirements of your motor, you may need to connect an external power source to the power input of your Arduino as well. For our version of this project, we used a AA battery pack.

DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Build A Robot with ArduinoBuild A Robot with Arduino
  • How to Find Out When Your Plants Need Watering with a Soil SensorHow to Find Out When Your Plants Need Watering with a Soil Sensor
  • Use Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the SteeringUse Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the Steering
  • Servo Motor Controlled Wireless Light SwitchServo Motor Controlled Wireless Light Switch
  • Arduino Explorer Rover Part 2 – Electronics & WiringArduino Explorer Rover Part 2 – Electronics & Wiring
  • DIY Drone Instructable: How To Deliver a PayloadDIY Drone Instructable: How To Deliver a Payload
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort