How to make a smart dustbin Arduino | Low cost smart dustbin Arduino

 Smart Dustbin Arduino Tutorial

How to make a smart dustbin Arduino

           Hello guys, welcome back to another blog from the SriTu Hobby. So, In this article, we will learn how to make a Smart dustbin using Arduino. For that, we can use the knowledge presented in previous articles. So, now first we will simply identify the components that are mainly needed for this Arduino smart dustbin project.

This Arduino smart dustbin project is based on the Arduino UNO board and uses an ultrasonic sensor and a servo motor to operate it. Also, we can get distances with an ultrasonic sensor. That theory has been used for this. Click this link for more information about Ultrasonic Sensor. Next, a servo motor is used to open and close the lid of this smart dustbin. So, A servo motor is used for this purpose as we can rotate it to the required degree. also, Click this link to know more about servo motor. (Note – This project is designed to be low cost)

This smart dustbin process

When you get close to this smart dustbin, the lid will open automatically. Then you can put unwanted material in it. Afterward, the lid will close after a while.

The following is a list of components that can be used to create this and You can purchase these components using the affiliate links below.

So, let’s do this project step by step

Step 1

Firstly, identify these components.

Arduino UNO board.

Ultrasonic sensor.

Servo motor.

Cardboard.
Jumper wires.
Phone batteries.
You can use any other power source.

Step 2

Secondly, we will cut the cardboard required for this. For this, cut four 6×6 inch pieces and two 6.25×6.25 inch pieces.
How to make a smart dustbin Arduino

Step 3

Thirdly, connect the ultrasonic sensor to a 6 * 6 piece.
How to make a smart dustbin Arduino

Step 4

Next, connect these 6 * 6 pieces to the 6.25 piece. For this, we can use a glue gun.

Step 5

Afterward, connect the Arduino Uno board and the Servo motor as follows.


(adsbygoogle = window.adsbygoogle || []).push({});

Step 6

Well, now we have to connect these components with the Arduino board. For that, use the circuit diagram below.
How to make a smart dustbin Arduino
How to make a smart dustbin Arduino

Step 7

Now attach the remaining (6.25×6.25 inch) piece of cardboard in the form of a smart dustbin lid and connect it to the servo motor using an iron wire.
How to make a smart dustbin Arduino
How to make a smart dustbin Arduino

Step 8

So, we will create the required program for this. Also, It can be seen below.
The complete program of this project – Download
/*Smart dustbin with Arduino.
  created by the SriTu Tech team.
  Read the code below and use it for any of your creations.
*/
 
#include <Servo.h> //include servo library
#define Trig 2
#define Echo 3
#define servo 6
 
Servo myservo;
void setup() {
  Serial.begin(9600);
  pinMode(Trig, OUTPUT);
  pinMode(Echo, INPUT);
  myservo.attach(servo);
}
 
void loop() {
  int dis = distance();
  Serial.println(dis);
 
 
  if (dis < 10) {
    myservo.write(0);
    delay(3000);
  } else {
    myservo.write(100);
  }
}
int distance() {
  digitalWrite(Trig, LOW);
  delayMicroseconds(4);
  digitalWrite(Trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(Trig, LOW);
 
  long t = pulseIn(Echo, HIGH);//input pulse and save it veriable
  long cm = t / 29 / 2; //time convert distance
  return cm;
}

Code explanation

The Servo library is included here first.
#include <Servo.h> //include servo library
 
Secondly, we define the Arduino pins used for this project and create an object called “servo” for the Servo library.
#define Trig 2
#define Echo 3
#define servo 6
 
Servo myservo;
 
thirdly, the PINS associated with the ultrasonic sensor in the Void configuration informs the Arduino board as output and input PIN, and the PIN associated with the servo motor is also notified to the library.
void setup() {
  Serial.begin(9600);
  pinMode(Trig, OUTPUT);
  pinMode(Echo, INPUT);
  myservo.attach(servo);
}
 
Afterward, an int type function is created to get the ultrasonic readings. Also, It is named as “distance” and It includes the program to get the distance through the ultrasonic sensor. Also, this distance is converted to CM and returned.
int distance() {
  digitalWrite(Trig, LOW);
  delayMicroseconds(4);
  digitalWrite(Trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(Trig, LOW);
 
  long t = pulseIn(Echo, HIGH);//input pulse and save it veriable
  long cm = t / 29 / 2; //time convert distance
 
  return cm;
}
 
Lastly, take the following return distance in the Void loop and test it with an IF condition, and if that value is less than 10cm the servo motor is activated and designed to open the lid on the dustbin.
void loop() {
  int dis = distance();
  Serial.println(dis);
 
 
  if (dis < 10) {
    myservo.write(0);
    delay(3000);
  } else {
    myservo.write(100);
  }
}

Step 9

So, now select the correct board and port and upload this code.

Step 10

Lastly, connect the phone batteries and power up the Arduino board. So, we can check out this design and the Full video guide is given below. We will meet in the next article soon.

How to make a smart dustbin Arduino | Low-cost smart dustbin Arduino

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top