Introduction: Trashcan Fill Level Indicator
First Prize in the
Home Technology Contest
As a way of learning basic programming and electronics, I attempted to design and create a trashcan that uses an ultrasonic sensor to detect the fill level of a trashcan, and a one digit LED counter to display how full the can is in an intuitive way. The counter displays an LED representation of the can and indicated that the can is full, halfway full, or less than halfway full. The can is controlled by an Arduino Uno powered by a 9.7v battery.
- Arduino Uno
- Limit Switch (I used a de-cased VEX one)
- Ultrasonic Sensor (Again, I used VEX)
- 10 K Ω Resistor
- One digit LED counter (I used an LDS-AA14RI)
- 2.1mm Center Positive Power Adapter
- Alligator Clips
- 9.7v Battery (VEX again for me)
Step 1: Soldering the Counter
For how we are using the counter, most of the 8 control pins can be soldered together. The only pins we need to directly control are for the middle and top horizontal line displays. For this particular counter, constant 5v is sent to two of the pins, and pins are grounded to display their value. As they should always be lit, we will ground the pins correlating to the outside displays of the counter. This frees up pins on our Arduino for anything else we may want to do. The two pins we do need control of have individual wires soldered on to them (color coding is important!).
Step 2: Making an Enclosure for the Counter
To help make the indicator a bit more attractive, I decided to make an enclosure for it. This step is somewhat optional, and you should mount your counter any way you want (I'm a big proponent of hot glue for anything). I made a quick design for an enclosure in Autodesk Inventor, and 3-D printed it using a Lulzbot Taz 2. However, there are many options for making your enclosure, and you should do something to make it your own
Step 3: Mounting the Counter
To mount the enclosure, you need to drill your holes for wire routing, and for bolting the enclosure onto the lid of the can . This step is fairly simple, but remember to make sure that you know where you want your counter before you drill.
Step 4: Mounting the Ultrasonic Sensor
Next up is mounting the sensor to detect fill level into the lid of the trashcan. I used a VEX ultrasonic sensor for this project as that was readily available, but pretty much any US sensor will do. I hot glued the sensor in place, but bolting it in will create a more permanent mounting.
Step 5: Route the Wiring
I used a single hole drilled into the back-center of the can to route my wiring. This actually worked very well for keeping everything organized, and will make your life significantly easier.
Step 6: The Limit Switch
We need to be able to sense when the lid of the can is open and when it is closed, so that we can prevent our fill indicator from changing while the lid is opened. To accomplish this, I mounted a limit switch to the side of our can. This switch is don when the lid is closed, and off when it is open. Ideally, you would use 4-40 screws to mount this switch, but those were unavailable to me at the time. So I used a method involving hot glue and 12 gauge wire that I would NOT recommend.
Step 7: Mounting and Wiring the Arduino
Next, we need to put on the brains of our waste receptacle. I used an Arduino Uno to power this project. I located the micro controller close to the routing hole for my wiring, and next to the limit switch. This Arduino is attached using three screws of an indeterminate size screwed directly into the side of the can. I also considered using zUNO Clips ( http://digilentinc.com/Products/Detail.cfm?NavPath=2,892,1256&Prod=ZUNO-CLIP), but didn't have enough printer time to get them done. Once the Arduino is mounted, it's time to start wiring. Its fairly straight forward, but there are a couple of things to note. If you are using a VEX limit switch, the black wire actually need to go to a constant 5v port on your microcontroller. You also need to add a 10k resistor stemming from the signal wire of the switch into ground. This is important for receiving a clear signal from your switch. Also be sure to wire the pins for the outside indicators of the counter straight to ground, unless you want them to be individually controllable.
Step 8: Mounting the Battery
To power the Arduino without a computer, we need to mount a battery onto the can. I did this by creating a pocket out of masking tape and hot gluing it to the side of the can. There are far more elegant solutions to this that you can use, and I would encourage you to do so. The battery is connected to the Arduino using a 2.1mm center positive plug soldered onto a pair of alligator clips. Using an actual battery connector is preferable, but not something I was able to do.
Step 9: Programming
This project was my first serious foray into coding, so this part took up the bulk of the time for this project. It changes the value displayed on the counter depending on the distance detected by the sensor. The program also has several checks to avoid changing value when it shouldn't. It will not update the value while the lid is open, and it will not change the value unless the detected fill level stays more or less constant for several seconds. This prevents the sensor from being tricked by thrown trash not settling immediately. The ranges used to update the indicator can be adjusted to better suit different sized cans, but the range of the US sensor is limited, so I wouldn't recommend anything much bigger than a standard kitchen trash can.
We have a be nice policy.
Please be positive and constructive.