Smart Dust Bin
For my project, I made a smart dustbin.
Placing objects in your dustbin and accidentally touching them can be unsanitary because they often require manual contact. This can spread germs and bacteria, especially in high-traffic areas (e.g. schools, hospitals, etc.) Using an ultrasonic sensor or a button to open the dustbin can be a lot more sanitary.
This project was inspired by previous ideas of dustbins that are contactless.
Supplies
Essential Components:
- Arduino board (e.g. Arduino UNO)
- Ultrasonic sensor (HC-SR04)
- Servo Motor1
- Breadboard and jumper wires
- Dustbin
- Cardboard
Optional Components:
- LCD display (with an I2C module for simplified connections)
- Push button for manual operation
- LED for status
Tools:
- Scissors
- Duct tape
- Double-sided tape
- Computer with Arduino IDE
The Circuit!
The circuit has three main components: the ultrasonic sensor, the servo motor, and the LCD display.
The circuit measures the distance using the ultrasonic sensor, and if it is below a certain threshold (such as 20cm), the servo is turned on and opens the trashcan. A button can also be clicked. When the button is clicked, the servo is turned on and it opens the trashcan as well.
The servo must be connected to a PWM pin because servos do require analog signals. The Arduino mimics analog signals by modulating the pulses of the digital signals—hence the name, pulse width modulation (PWM).
There is an LCD to let you know of the status. The LCD is communicated through the I2C communication protocol. The I2C allows for multiple devices to communicate with each other. Data is sent through the SDA line; the clock signal is sent through the SCL line.
LEDs are also used to let you know that the trash can is turned on.
Connect Ultrasonic Sensor and Servos
Take your breadboard. Wire the Arduino, the ultrasonic sensor, and the servos together.
Connect the 5V pin from the Arduino to the positive rail of the breadboard. Connect the ground pin from the Arduino to the negative rail of the breadboard.
For the ultrasonic sensor, connect VCC to the positive rail, GND to the negative rail, the TRIG pin to pin 9 in the Arduino, and the ECHO pin to pin 10 in the Arduino.
To connect the servos, connect the VCC to the positive rail, the GND to the negative rail, and the signal wire to pin 6.
Connect the LCD
Connect the LCD to the breadboard. Make sure that the LCD is connected to an I2C module.
I2C is used for short-distance communication. It consists of two wires: SDA and SCL, which allow for bidirectional communication across the serial bus. Although the LCD an be connected without the I2C module, using the I2C module makes development faster and easier.
Connect the VCC of the LCD to the positive rail, the GND of the LCD to the negative rail, the SDA pin to A4, and the SCL pin to A5.
Add Cardboard to the Head of the Servo
Cut out a piece of cardboard to serve as the lid for your dustbin. Measure accordingly. Use duct tape to tape on the head of the servo to the piece of cardboard. Use multiple layers of tape if necessary.
Optional: You can layer on another layer of cardboard to sandwich the head of the servo. This can improve the stability of the lid as the servo would not easily come off.
Attach Project to Dustbin
Attach the project to the dustbin using double-sided tape. This requires adding the servo to the dustbin and the LCD to the dustbin using double-sided tape.
When attaching the servo, make sure that the lid of the trash can can rotate fully.
Code
Copy the code attached and paste it on Arduino IDE.
If needed, the threshold can be updated to better work in the environment that the dustbin is in. In the code attached, the threshold is 20. Changing the constant THRESHOLD can be used to optimize for the environment.
The code uses the LiquidCrystal_I2C library to be able to control the LCD much more easily.
Furthermore, the code uses functions, loops, and arrays to clean up the code and improve it.
Downloads
Done!
Once the code is uploaded, the wire can be disconnected from the Arduino, a battery can be attached, and the trash can can be used!