Introduction: Arduino Anti-Dog Trash Can
In this project I will show you how to build a ridiculous but working method to prevent your pesky dogs from getting into your trash can!
Step 1: Intro
My dog is a beagle and can't help but smell all that delicious garbage in the trash bin. This leads him to constantly be trying to get his nose into the garbage and get into whatever he can. I thought that buying a trash can with a step controlled lid would solve this problem once and for all. Little did I know, my dog outsmarted the can and figured out almost instantly he could use his snout to pop the lid open and get all the trash he wanted. I could put a weight on the lid to prevent this but that sounds lame and I am stuck at home due to the quarantine so I built this anti-dog trash can.
It is a simple project and could be used as a great introduction into sensors, electronics, and programming.
Please consider subscribing to my YouTube channel to support me and to see more fun projects.
Step 2: Components Needed
The components needed for this project are below:
1. Arduino Uno or Nano (Amazon Link)
2. Resistors (10K Ohm, 10 Ohm) (Amazon Link)
3. Capacitors(10uF x 2, 220uF,.05 uF) (Amazon Link)
4. 10K Potentiometer (Amazon Link)
5. Micro SD Card Module (Amazon Link)
6. Limit Switch (Amazon Link)
7. 9V-12V Power Supply for Arduino (Amazon Link)
8. 8 Ohm Speaker (This one is different than mine but it should work)
9. LM 386 Amplifier (Amazon Link)
Disclosure: The amazon links above are affiliate links, meaning, at no additional cost to you, I will earn a commission if you click through and make a purchase.
Step 3: Formatting Your Audio Files
In order to play your audio files that you can get online or record yourself to play when you dog opens the garbage can lid, you need to convert them to the correct format.
To do this go to https://audio.online-convert.com/convert-to-wav and set your files to the setting shown in the picture.
Once they are converted put them on the SD card with the names "1.wav", "2.wav", etc..
Step 4: Electronics
Now that you have gathered all of the required components, it is time to start assembling everything together. I would recommend wiring up everything on a breadboard first and then once everything is functioning properly go ahead and solder everything up on a perf board. I decided to keep it on a breadboard since after running it for a few days, my dog actually stopped trying to go in the garbage.
This circuit is very simple and made up of only a few parts.
First, we have an Arduino Uno which is connected to a limit switch, Micro SD card module, and to a LM386 amplifier which is connected to your speaker.
On the micro SD card module you should have all of your audio files now in the correct format. You connect the module using the SPI protocol and using the SD module library.
Then there is the limit switch with a pull up resistor. Connect GND to the Common side of the switch and the NO to Digital Input 2. The pull up resistor will make the default value on the input HIGH, and when the limit switch is on, it will be LOW. When the garbage lid is lifted, then we will see a HIGH signal on our trash can and can start out countdown from 4, 3, 2, 1 before triggering a .wav file on the sd card.
The Arduinos output is not strong enough to run your speaker so we need an amplifier which in this case is an LM386. The gain of the amplifier is given by the capacitor connected to pin 1 and 8 which in this case is a 10 UF which sets the gain to 200, without the capacitor it will be 20 according to the datasheet. The potentiometer controls the volume of the amplifier.
Step 5: Programming
I will assume that you know how to program your arduino but if not, there are many great tutorials available online.
You will need to install the following libraries in order for the code to compile.
Once you have the libraries installed, download the .ino file attached to this step in the instructable and upload it to your arduino.
The program is very simple and waits for the limit switch to open (showing the trash can is open) and then starts a count down for 4 seconds. If the limit switch is not closed in 4 seconds than the arduino will read an .wav file from the sd card connected to the module. The file will play through the speaker.
The current program requires 7 different audio files and cycles through them one after another each time it is triggered. You can adjust this to as few or as much sounds as you want just keeping the current pattern.
Step 6: Test It Out!
Now that you have made your trash can dog proof, it is time to test it out!
Plug in power and enjoy your new dog-free trash can. Please consider subscribing to my YouTube channel to support me and see more projects/videos. Thank you for reading!