The cats at my parent's house have a lounge on top of the parked cars where they sleep, jump up and off of them, and genuinely have a grand time in the process. The muddy paw prints were just annoying, until I noticed scratches on my car. Upon detailed inspection of my parents cars I noticed many paw scratches on the vehicles... no no no. So I took it upon myself to fix this problem. I figured if I put motion sensors, a motorcycle horn, an Arduino, and a battery in a box, I could ruin the cats' fun. This is my project.
Step 1: Materials
What you'll need:
Materials (Total = $76.56)
- Box to house all components (Mine is a Uxcell 230mm x 150mm x 85mm) - $12.31
- Arduino (I used an Ebay Chinese one) - $4
- Uxcell DC 5V Coil Relay - $2.57
- IR receiver - $1
- Talentcell Rechargeable 6000mAh Li-Ion Battery - $29.99 (This is overkill for this project)
- 2x EMY HC-SR501 PIR sensor - $4
- Cockscomb DC/DC Converter 12V Step Down to 9V 2A 18W - $7.88
- Uxcell Horn - $7.81 NOTE: Had trouble with horn working correctly with battery so replaced with Uxcell Buzzer
- 1/4 inch thick piece of wood - Free
- 2x AFUNTA 2.1 x 5.5 mm male DC power adapters - $2
- Heat srink - $1
- 4 mm bolts and nuts (I used 6)- $2
- 2x 6 mm bolts and nuts - $1
- 1/4 inch bolt and nut - $1
- Soldering iron
- Table or bandsaw to cut wood
- Dremel for plastic box
- Hot glue gun
Step 2: Housing, Wood Insert, and Installation of PIR and IR Sensors
The PIR sensors need to protrude out the side of the box to work. Since I decided to use two PIR sensors I decided to place one out each side. Their position is arbitrary but mine are placed on the horizontal centerline (Figure provided) and 1.75 inch from the closest side. The hole to fit the PIR sensors are 1 x 1 inch.
For the single IR sensor its position is arbitrary as well. Depending on where the box is placed should be considered when placing the sensor. For my application, the left side (side oriented towards house) is chosen for the for the IR sensor for a direct line of sight to the TV remote (so device can be turned on/off). Three 2mm holes were drilled at locations shown in attached Figure.
Both the PIR and IR sensors were hot glued in. Special attention was given to prevent water from entering the box.
For the wooden insert a section of 1/4 inch thick wood was quickly measured and cut to be able to fit inside. Give the sections around the PIR sensors in the walls plenty of room to avoid collisions while later inserting the electrical board. The electrical components were then placed on top of the plank and their outlines traced with a sharpie, including their holes. The holes were drilled out to accommodate 4 mm bolts for the arduino and relay, 6 mm bolts for voltage step down, and 1/4 inch bolt for the horn hole. After programming the battery will sit under this board.
This completes the box's construction.
Step 3: Wiring
Attached is the wiring diagram. Note that there are varying types of components similar to mine. Depending on your component(s) type/brand could cause variation in your own wiring.
NOTE: When working with PIR sensors I found that they are very sensitive with the voltage applied to them. Do not run them to a digital powered pin! You would receive enormous amounts of false positives.
Also try to cut and solder the wires so that it doesn't make a bird nest inside the box. This will make life easier.
Step 4: Programing
There are two programs needed to make this thing work:
- To determine the IR remote signal to operate the device which will be overwritten
- To operate the device using data collected by the first program
NOTE:You need to install the IR library (link: https://github.com/z3t0/Arduino-IRremote)
Program #1: With the 12v power disconnected connect the usb to the arduino and upload. Once running open the serial prompt. With the desired remote press the button which is wanted to turn on the device. Record value. Repeat again with the button to turn off the device and again, record the value.
Disclaimer: Program #1 or originally called "IRrecvDemo" was written by Ken Shirriff, Copyright 2009. It is an example from the IR library download (only with "RECV_PIN" changed to 2). I renamed it to avoid any confusion between the two programs.
Program #2: Go to line 32 and paste in your "turn on" value. Go to line 43 and paste or "turn off" value. Upload to your arduino.
The arduino is now programmed. Reconnect your 12v power cable.
To debug, the serial monitor can be opened.
Column 1 - PIR sensor: 1 means PIR sensor detected motion, 0 is waiting for motion
Column 2 - PIR sensor: 1 means PIR sensor detected motion, 0 is waiting for motion
Column 3 - State (If the alarm is on or off): 1 if on, 0 if off
The serial monitor will also display when the horn is active.
Note: When playing with the program tune (if able) your PIR sensors. I set my sensors to the "retrigger" mode, max sensitivity, and minimized the time delay.
Step 5: Placement
You're all done. Place on top of your vehicle where the PIR sensors will detect motion and use the remote to activate the alarm. Turning on is indicated by two beeps while off is a single honk of the horn.
This should bum out those cats.