Hi, I'm @techlhab and today I would be sharing with us how to make is DIY Smart Waste Bin using Arduino Uno microcontroller, Ultrasonic Sensor, and Servo Motor as the major hardware components and other hardware components which include a TP4056 lithium battery charging module, control switch, LED (Light Emitting Diode), Resistor, and connecting wires. While the software components are; the Arduino IDE, Embedded C/C++ programming language, and fritzing for circuit design and simulation.
- Arduino Uno
- Ultrasonic Sensor (HC-SR04)
- Servo Motor (SG90)
- 3.7v Rechargeable Lithium Battery x2
- TP4056 Lithium Battery Charging Module
- LED (Light Emitting Diode)
- Resistor (220 ohms)
- Control Switch
- Connecting Wires
- Arduino IDE (Integrated Development Environment)
- Embedded C/C++
- Fritzing
The Arduino Uno is a popular open-source microcontroller that uses the ATMEGA328P PIC (Programmable Integrated Circuit) chip developed by Arduino.cc. It has 14 digital I/O (Input / Output) pins and 6 analog I/O pins.
In this project, that is the smart waste bin, the Arduino Uno microcontroller serves as the brain of the device, with which other components connected to it sends and receives instructions to and from respectively based on the code or instructions programmed to the microcontroller.
The ultrasonic sensor is a sensor used in measuring distance or proximity. It transmits and receives sound waves and then converts the reflected sound wave over a distance from an object into electrical signals.
It has 4 pins which are:
- Vcc
- Gnd
- Trig
- Echo
In this project or tutorial, the HC-SR04 ultrasonic sensor is used and it is been used to sense the proximity of a person intended to dump waste into the bin at a programmed distance. Then sends the instruction to the Arduino Uno for other decision makings.
It is a micro motor that converts electrical signals to produce rotary effects, with which the speed, angular or linear position, velocity and acceleration can be controlled precisely with a microcontroller like the arduino uno.
In this project or tutorial, the servo motor is used in opening and closing the top lid of the waste bin.
The TP4056 lithium battery recharging module helps in recharging the lithium batteries through an external 5v voltage source. It has two LEDs on it with which one of them indicates a red light to notify that the battery is charging and the other one is a blue LED which indicated when the battery if fully charged.
Two 3.7v rechargeable lithium batteries are used and are connected in parrallel in to other to maintain the voltage of 3.7v and double the current by two in other to make the batteries power the smart waste bin for longer or hours.
The resistor is an electronics component that is used in reducing, limiting or varying the electric current following through a path or other components in an electric circuit.
In this project, the 220 ohms resistor helps in limiting the current that goes into the LED (Light Emitting Diode) due to the higher voltage coming from the microcontroller which is needed to be reduced before getting to the LED in other to protect it from damaging as it requires only 3.3v. And from ohm's law current is directly proportional to voltage, a decrease in current would lead to a decrease in voltage as V = IR
.
The LED (Light Emitting Diode) is a highly utilized electronic component that converts electrical energy into light energy. That is produces light when voltage is been applied to its two terminals. It is polarized which means on like the resistor the LED has positive and negative terminals and must be checked appropriately before applying voltage to its terminals.
In this project, the LED is used to indicated that electric power supply has been supplied to the circuit.
The switch is an electronics component that is used to make or break electric connections in an electric circuit.
In this project or tutorial, it is used in switch on and off power supply to and from the smart waste bin.
- Conneting the ultrasonic sensor to the Arduino Uno
Arduino Uno | Ultrasonic Sensor | |
---|---|---|
1 | 5v | Vcc |
2 | Gnd | Gnd |
3 | D4 | Trig |
4 | D3 | Echo |
- Conneting the Servo Motor to the Arduino Uno
Arduino Uno | Servo Motor | |
---|---|---|
1 | 5v | Vcc |
2 | Gnd | Gnd |
3 | D5 | Pulse or Signal Pin |
#include <Servo.h>
Servo servoMain; // Define our Servo
int trigpin = 4;
int echopin = 3;
int distance;
float duration;
float cm;
void setup()
{
servoMain.attach(5); // servo on digital pin 5
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
}
void loop()
{
digitalWrite(trigpin, LOW);
delay(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);
cm = (duration/58.82);
distance = cm;
if(distance<30)
{
servoMain.write(180); // Turn Servo back to center position (90 degrees)
delay(3000);
}
else{
servoMain.write(0);
delay(50);
}
}
When the device is been switched on using the control switch, the red LED comes on to indicate that power has been supplied to the circuit.
The microcontroller has been programmed that whenever the ultrasonic sensor radiated sound wave is been reflected or obstructed within a distance of 30cm then, it instructs the servo motor open the lid of the smart waste bin and wait for 3 seconds then closes smart waste bin lid when the distance between the person intending to dump a refuse or waste and the smart waste bin is more than 30cm. But as long as the person intending to dump the refuse into the waste bin is still within 30cm distance the lid would remain open waiting for the person to dump the refuse and close itself automatically after the person as dumped the refuse and moved away from the smart waste bin.
The TP4056 lithium battery charger module recharges the batteries easily and ensure that the device keep on functioning and that the batteries are having adequate potential to power the device.
Thanks for reading and visiting my blog 🤝. Kindly support this post by reblogging, upvoting, and commenting, it would be highly appreciated.
Images used in this post were all designed by me using fritzing, a circuit design and simulation software.
Posted with STEMGeeks