My Idea For this week is to make a smart trash bin, this idea has many advantages
Hands-free operation: By using an ultrasonic sensor to detect when a person's hand or waste is near the bin, the lid can be opened automatically without the need for the person to touch the bin. This can help to reduce the spread of germs and bacteria, which is especially important in public areas.
Efficient waste management: By using a temperature sensor to monitor the temperature inside the bin, the system can determine when the bin needs to be emptied or when the contents are starting to decompose. This can help to improve waste management by ensuring that the bins are emptied at the right time and reducing the risk of odors and pests.
User-friendly interface: By using an I2C LCD to display the temperature readings, the system provides a user-friendly interface that makes it easy to monitor the status of the bin. This can help to improve user engagement and encourage people to use the bin more effectively.
Overall, your smart trash bin project has the potential to make waste management more efficient, hygienic, and user-friendly. It could be useful in a range of settings, such as public areas, offices, homes, and other environments where efficient waste management is important.
To Design the Circuit
To Write The Code
Ultrasonic Sensor
Wires
Arduino UNO
Breadboard
I2C LCD
Temprature Sensor
Servo Motor
I used BRM Lasers 150 WATT Machine to cut the bin frame and Digital Vernier Caliper for measuring some distance you will know below
First, let's start with the ultrasonic sensor. This sensor is used to measure the distance between the trash bin and the object in front of it, in this case, a person's hand or waste. The ultrasonic sensor emits high frequency sound waves and measures the time it takes for the sound waves to bounce back from the object. This time is then used to calculate the distance between the sensor and the object.
The temperature sensor is used to measure the temperature inside the trash bin. This information can be useful to determine if the bin needs to be emptied or if the contents are starting to decompose.
The I2C LCD is used to display the temperature readings. The I2C interface allows the Arduino to communicate with the LCD using only two wires, which makes it easy to connect and use.
The servo motor is used to open and close the lid of the trash bin. When the ultrasonic sensor detects an object within a certain distance (e.g. a person's hand), the servo motor will activate and open the lid of the bin to allow the object to be deposited inside. Once the object is deposited, the servo motor will close the lid.
To implement this idea, we will need to connect the ultrasonic sensor, temperature sensor, I2C LCD, and servo motor to the Arduino board. we will also need to write a program in the Arduino IDE that reads the distance and temperature sensors, displays the readings on the LCD, and controls the servo motor based on the distance readings.
Here is a basic outline of the program:
Initialize the ultrasonic sensor, temperature sensor, I2C LCD, and servo motor.
In the loop function, read the distance and temperature sensors.
Display temperature readings and some texts like ( Put Your Trash Here ) on the LCD.
If the distance reading is below a certain threshold (e.g.10 or 15 cm), activate the servo motor to open the lid of the trash bin.
Wait for a certain amount of time (e.g. 5 seconds) to allow the object to be deposited.
Activate the servo motor to close the lid of the trash bin.
Repeat the loop.
Bin Design
I use this freepik design as my bin design but i did some edits like making two holes for Ultrasonic and one rectangle for LCD
Measuring Ultrasonic eyes diameter (16mm)
Measuring the distance between ultrasonic eyes (11mm)
Measuring LCD screen length (72mm)
Coding
I developed this code to use an ultrasonic sensor and a servo motor to create a smart trash that can opens automatically when someone approaches it. It also displays the temperature inside the trash can on an LCD screen.
The first few lines of the code include the necessary libraries and declare the necessary variables.
The Wire.h library is used for I2C communication
LiquidCrystal_I2C.h is used for controlling the LCD screen
Servo.h is used for controlling the servo motor.
The Servo A declaration creates an instance of the Servo class called A, which is used to control the servo motor.
The tempsensor variable is set to A0, which is the pin that the temperature sensor is connected to.
The LiquidCrystal_I2C declaration creates an instance of the LiquidCrystal_I2C class called lcd, which is used to control the LCD screen.
The readUltrasonicDistance function is used to measure the distance using the ultrasonic sensor. It takes two arguments, triggerPin and echoPin, which are the pins that the ultrasonic sensor is connected to. The function first clears the trigger pin, sets it to a low state, and waits for 2 microseconds. It then sets the trigger pin to a high state for 10 microseconds and then sets it back to a low state. It sets the echo pin to an input mode, reads the echo pin, and returns the sound wave travel time in microseconds.
the state boolean variable bool state=false; is used to keep track of whether the trash can lid is open or closed. It is initialized to false in the beginning of the code.
When someone approaches the trash can and the distance measured by the ultrasonic sensor is less than or equal to 30, the state variable is set to true, which indicates that the lid is open.
When the lid is open, the LCD screen displays the message "Put Your Trash Here", and the servo motor is set to the 140-degree position to keep the lid open. This is done in the following lines of code:
lcd.clear();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Put Your Trash Here");
delay(1000);
A.write(140);
When the distance measured by the ultrasonic sensor is greater than 30, the program checks the value of the state variable. If it is true, it means the lid was previously open, so the LCD screen displays the message "Thank You" and the servo motor is kept at the current position to keep the lid open. This is done in the following lines of code:
if (state == true) {
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Thank You");
delay(1000);
}
Eng/Menna Elbadry is who advise me to use the boolean here in this part, thank you <3
The void setup function initializes the variables and sets up the necessary pins and communication protocols.
The A.attach(9) function attaches the servo motor to pin 9.
The A.write(0) function sets the servo motor to the 0-degree position.
The pinMode(A0, INPUT) function sets pin A0 to an input mode for the temperature sensor.
The lcd.init() function initializes the LCD screen.
The Serial.begin(9600) function initializes the serial monitor with a baud rate of 9600.
The Serial.print(0.01723 * readUltrasonicDistance(2, 3)) function prints the distance measured by the ultrasonic sensor to the serial monitor.
The loop function is the main loop of the program. It checks if someone is close to the trash can by using the `readUltrasonicDistance` function and multiplying it by `0.01723` to convert it to the cm unit. If the distance is less than or equal to 30cm, it means someone is close to the trash can, so the `state` variable is set to `true`. The LCD screen is cleared, turned on, and displays the message "Put Your Trash Here". The servo motor is then set to the 140-degree position, which opens the lid of the trash can.
If the distance is greater than 30cm, it means no one is close to the trash can. If `state` is `true`, it means someone was previously close to the trash can, so the LCD screen is cleared and displays the message "Thank You" for 1 second. If `state` is `false`, it means the trash can was already closed, so the LCD screen is cleared, turned off, and the servo motor is set to the 0-degree position, which closes the lid of the trash can.
If the distance measured by the ultrasonic sensor is neither less than or equal to 30 nor greater than 30, the program assumes that the trash can is empty and displays the temperature inside the trash can on the LCD screen. The temperature is calculated by reading the analog value from the temperature sensor connected to pin A0 and converting it to Celsius.
Overall, this code demonstrates how an ultrasonic sensor and a servo motor can be used to create a smart trash can that opens automatically when someone approaches it. It also shows how an LCD screen and a temperature sensor can be used to provide additional information to the user.
Wiring & Testing
Wiring The Temperature Sensor and test the reads on serial monitor
Wiring The Ultrasonic and test it's reads with serial monitor
Wiring All Circuit
Implementation
"The more operations, the more problems"
Software problem
Is how to make the screen turn off until I get close to the basket, and then the phrase “Put your trash here” is displayed, and it waits until I go away and then it displays “Thank you.”
The problem here is if I approached and the screen lit up and displayed the sentence and I moved away from it and displayed thank you when will the screen turn off? How will the basket know if I was in front of the basket, and it would display Thank you, or if I did not come close to the basket, so it would be extinguished?
Engineer Menna Elbadry helped me a lot with that (Thank you Menna <3)
I defined a Boolean called State (In computing, the term Boolean means a result that can only have one of two possible values: true or false)
and it represents the condition of the basket. We defined it as False at the beginning, and when I approached the basket, the condition becomes True.
Then we made the code check if the condition is true or false
If it is correct, this means that I was in front of the basket, then it will show me "Thank you" and if it is wrong, this means that I was not near the basket, then the screen will be off
Implementaion problem
There was a problem with the cover of the basket. It had sides for the cover in the design, and after assembling these sides, it caused friction with the body of the basket, and this makes the servo unable to lift it and makes the cover not close completely.
In fact, the design was more suitable for a box than a basket
I cut those sides to close easily, but the final shape was not what it should be, so try to find a more suitable design than that (do not postpone the weekly assignment in order to find time for that)
Special Thanks for my college Khadija Radwan who helped me on fabrication on her In its MM LAB at the Faculty of Applied Arts at the German University