HOW TO MAKE A SMART WASTE BIN USING ARDUINO UNO | SERVO MOTOR | ULTRASONIC SENSOR - EXPLAINED IN DETAILS

in STEMGeeks3 years ago

SMART WASTE BIN.png

<p dir="auto"><span>Hi, I'm <a href="/@techlhab">@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. <hr /> <p dir="auto"><strong><center>HARDWARE COMPONENTS <hr /> <ul> <li>Arduino Uno <li>Ultrasonic Sensor (HC-SR04) <li>Servo Motor (SG90) <li>3.7v Rechargeable Lithium Battery x2 <li>TP4056 Lithium Battery Charging Module <li>LED (Light Emitting Diode) <li>Resistor (220 ohms) <li>Control Switch <li>Connecting Wires <hr /> <p dir="auto"><strong><center>SOFTWARE COMPONENTS <hr /> <ul> <li>Arduino IDE (Integrated Development Environment) <li>Embedded C/C++ <li>Fritzing <hr /> <p dir="auto"><strong><center>The Arduino Uno <hr /> <p dir="auto">The Arduino Uno is a popular open-source microcontroller that uses the ATMEGA328P PIC (Programmable Integrated Circuit) chip developed by <a href="https://www.arduino.cc/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Arduino.cc. It has 14 digital I/O (Input / Output) pins and 6 analog I/O pins. <p dir="auto">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. <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/244xyyyQn72SM1qWMGVMY2A2KDdotE3DHveszmgXZEFgQiRDdykRBgK5LjT3g3imKaEs5.png" alt="arduino.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/244xyyyQn72SM1qWMGVMY2A2KDdotE3DHveszmgXZEFgQiRDdykRBgK5LjT3g3imKaEs5.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/244xyyyQn72SM1qWMGVMY2A2KDdotE3DHveszmgXZEFgQiRDdykRBgK5LjT3g3imKaEs5.png 2x" /> <hr /> <p dir="auto"><strong><center>The Ultrasonic Sensor <hr /> <p dir="auto">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. <p dir="auto">It has 4 pins which are: <ul> <li>Vcc <li>Gnd <li>Trig <li>Echo <p dir="auto">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. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23qrUvVmHXVtPfx79wV4aSTXb7qDxVcWQhrkHBUcQFtcip2EcoGEN9XwjMHhXrpqsQkBV.png" alt="UL.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23qrUvVmHXVtPfx79wV4aSTXb7qDxVcWQhrkHBUcQFtcip2EcoGEN9XwjMHhXrpqsQkBV.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23qrUvVmHXVtPfx79wV4aSTXb7qDxVcWQhrkHBUcQFtcip2EcoGEN9XwjMHhXrpqsQkBV.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The Servo Motor <hr /> <p dir="auto">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. <p dir="auto">In this project or tutorial, the servo motor is used in opening and closing the top lid of the waste bin. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23rBKy5LGJWXUemm7PZkd61uPbxqp14WZaCJ3RvdMCex5rx6Csiir1EN9afbZbbFXLftv.png" alt="SERVO.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23rBKy5LGJWXUemm7PZkd61uPbxqp14WZaCJ3RvdMCex5rx6Csiir1EN9afbZbbFXLftv.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23rBKy5LGJWXUemm7PZkd61uPbxqp14WZaCJ3RvdMCex5rx6Csiir1EN9afbZbbFXLftv.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The TP4056 Lithium Battery Charger Module <hr /> <p dir="auto">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. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23sURBeeEDAzqzu67XS8sHEBpNZWZxQ27z9K52tExKKAK6VVNovXYJLiwRzvmUNnW4ZxR.png" alt="TP.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23sURBeeEDAzqzu67XS8sHEBpNZWZxQ27z9K52tExKKAK6VVNovXYJLiwRzvmUNnW4ZxR.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23sURBeeEDAzqzu67XS8sHEBpNZWZxQ27z9K52tExKKAK6VVNovXYJLiwRzvmUNnW4ZxR.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The 3.7v Lithium Rechargeable Battery <hr /> <p dir="auto">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. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/243MQGs9jqiCt9V4n7YvE53mgbXY4xHZNAjaNMT5ovbYHd6GoKehWgSKpCyprTXsVfn8D.png" alt="LIPO.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/243MQGs9jqiCt9V4n7YvE53mgbXY4xHZNAjaNMT5ovbYHd6GoKehWgSKpCyprTXsVfn8D.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/243MQGs9jqiCt9V4n7YvE53mgbXY4xHZNAjaNMT5ovbYHd6GoKehWgSKpCyprTXsVfn8D.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The Resistor <hr /> <p dir="auto">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. <p dir="auto">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 <code>V = IR. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23wMyoF4ozqRJSvCUVCGoQCMWYZXjCetr6xTCtXeZAgii6sBZWFojMnnamAV2ZovUBgcQ.png" alt="resistor.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23wMyoF4ozqRJSvCUVCGoQCMWYZXjCetr6xTCtXeZAgii6sBZWFojMnnamAV2ZovUBgcQ.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23wMyoF4ozqRJSvCUVCGoQCMWYZXjCetr6xTCtXeZAgii6sBZWFojMnnamAV2ZovUBgcQ.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The LED (Light Emitting Diode) <hr /> <p dir="auto">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. <p dir="auto">In this project, the LED is used to indicated that electric power supply has been supplied to the circuit. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23tmmf76KUee367xJ8V9pAeYU5fXqPWLV4x4jtRJKkjfnYX2NJFswGZEpSfy4PwVyb7RY.png" alt="led.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23tmmf76KUee367xJ8V9pAeYU5fXqPWLV4x4jtRJKkjfnYX2NJFswGZEpSfy4PwVyb7RY.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23tmmf76KUee367xJ8V9pAeYU5fXqPWLV4x4jtRJKkjfnYX2NJFswGZEpSfy4PwVyb7RY.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>The Control Switch <hr /> <p dir="auto">The switch is an electronics component that is used to make or break electric connections in an electric circuit. <p dir="auto">In this project or tutorial, it is used in switch on and off power supply to and from the smart waste bin. <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/245HpzMR8rMPRany7r38ah9UJFwEHtc6eDF8vnJfHmEa1vwqZFhqZtdLiMzebPLapNNCg.png" alt="S.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/245HpzMR8rMPRany7r38ah9UJFwEHtc6eDF8vnJfHmEa1vwqZFhqZtdLiMzebPLapNNCg.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/245HpzMR8rMPRany7r38ah9UJFwEHtc6eDF8vnJfHmEa1vwqZFhqZtdLiMzebPLapNNCg.png 2x" /><br /> <hr /> <p dir="auto"><strong><center>THE HARDWARE CONNECTIONS <hr /> <ul> <li><strong>Conneting the ultrasonic sensor to the Arduino Uno <div class="table-responsive"><table> <thead> <tr><th><th>Arduino Uno<th>Ultrasonic Sensor <tbody> <tr><td>1<td>5v<td>Vcc <tr><td>2<td>Gnd<td>Gnd <tr><td>3<td>D4<td>Trig <tr><td>4<td>D3<td>Echo <ul> <li><strong>Conneting the Servo Motor to the Arduino Uno <div class="table-responsive"><table> <thead> <tr><th><th>Arduino Uno<th>Servo Motor <tbody> <tr><td>1<td>5v<td>Vcc <tr><td>2<td>Gnd<td>Gnd <tr><td>3<td>D5<td>Pulse or Signal Pin <hr /> <p dir="auto"><strong><center>THE CIRCUIT DIAGRAM <hr /> <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23tSym8QDvjZCj3wy8ERSMjgADmbQeJRUFhNoz9foCGLiqGZ4V3YUJaf2B7sMPQZ5Gd4V.png" alt="SMART WASTE BIN_schem.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/techlhab/23tSym8QDvjZCj3wy8ERSMjgADmbQeJRUFhNoz9foCGLiqGZ4V3YUJaf2B7sMPQZ5Gd4V.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/techlhab/23tSym8QDvjZCj3wy8ERSMjgADmbQeJRUFhNoz9foCGLiqGZ4V3YUJaf2B7sMPQZ5Gd4V.png 2x" /> <hr /> <p dir="auto"><strong><center>THE CODE <hr /> <pre><code>#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); } } <hr /> <p dir="auto"><strong><center>HOW DOES IT WORKS? <hr /> <p dir="auto">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. <p dir="auto">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. <p dir="auto">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. <p dir="auto">Thanks for reading and visiting my blog 🤝. Kindly support this post by reblogging, upvoting, and commenting, it would be highly appreciated. <p dir="auto"><em><sub>Images used in this post were all designed by me using <a href="https://fritzing.org" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">fritzing, a circuit design and simulation software. <p dir="auto">Posted with <a href="https://stemgeeks.net" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">STEMGeeks
Sort:  

I would have loved to try this but I don't think I am smart enough 😆

Thanks for commenting @khaleesii 🤝. We can actually do anything we put our minds to @khaleesii and most times it's not about being smart. Its a matter of interest, dedication, commitment and consistency.

Thank you, maybe ill put my mind to it and give it a try.

 3 years ago  

Do you have a picture of a finished product for reference?

!discovery 37

Thanks for commenting @enforcer48 🤝. Yeah I do have an image of the finished product, and here it goes...

20220331_150952.jpg

 3 years ago  

Nice.

Thanks @enforcer48 🤝. I so much love and enjoy Building solutions by applying my acquired skills in making life easier and smarter. And also sharing the knowledge for other to benefit from.


This post was shared and voted inside the discord by the curators team of discovery-it
Join our community! hive-193212
Discovery-it is also a Witness, vote for us here
Delegate to us for passive income. Check our 80% fee-back Program

Your content has been voted as a part of Encouragement program. Keep up the good work!

Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for new Proposal
Delegate HP and earn more

Congratulations @techlhab! You received a personal badge!

You powered-up at least 10 HIVE on Hive Power Up Day!
Wait until the end of Power Up Day to find out the size of your Power-Bee.
May the Hive Power be with you!

You can view your badges on your board and compare yourself to others in the Ranking

Check out the last post from @hivebuzz:

Hive Power Up Day - April 1st 2022
Support the HiveBuzz project. Vote for our proposal!

This is a really cool device. I noticed that you shared a picture of the finalised project. Would it be possible to also share a small video to see it in action? Thanks in advance ^^

Cheers!

Thanks for the nice comment @lemouth 🤝. I'm currently not within where I installed the device and I don't have the video of it on my phone, I only took pictures of it after development. But I would send the video of it working when I get to it as soon as possible. Thanks.

Cool cool! I am looking forward to see it. You managed to trigger my curiosity quite a bit ;)