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

in #hive-1635213 years ago

SMART WASTE BIN.png

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.


HARDWARE COMPONENTS


  • 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

SOFTWARE COMPONENTS


  • Arduino IDE (Integrated Development Environment)
  • Embedded C/C++
  • Fritzing

The Arduino Uno


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.

arduino.png


The Ultrasonic Sensor


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.


UL.png


The Servo Motor


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.


SERVO.png


The TP4056 Lithium Battery Charger Module


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.


TP.png


The 3.7v Lithium Rechargeable Battery


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.


LIPO.png


The Resistor


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.


resistor.png


The LED (Light Emitting Diode)


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.


led.png


The Control Switch


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.


S.png


THE HARDWARE CONNECTIONS


  • Conneting the ultrasonic sensor to the Arduino Uno
Arduino UnoUltrasonic Sensor
15vVcc
2GndGnd
3D4Trig
4D3Echo
  • Conneting the Servo Motor to the Arduino Uno
Arduino UnoServo Motor
15vVcc
2GndGnd
3D5Pulse or Signal Pin

THE CIRCUIT DIAGRAM


SMART WASTE BIN_schem.png


THE 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);

}

}

HOW DOES IT WORKS?


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

Sort:  

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

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 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 ;)

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.

👍


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

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!

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

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.