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

How to make a smart dustbin Arduino | Low cost 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 learn more about servo motors. (Note – This project is designed for 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.

OK, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Step 2

Secondly, let’s cut the cardboard pieces. For this, cut four 6×6 inch pieces and two 6.25×6.25 inch pieces.

Step 3

Thirdly, connect the ultrasonic sensor to a 6 * 6 piece.

Step 4

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

Step 5

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

Step 6

Now, connect these components to the Arduino board. For that, use the circuit diagram below.

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

Step 7

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

Step 8

So, we will create the required program for this.

  • 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.

Secondly, we define the Arduino pins used for this project and create an object called “servo” for the Servo library.

In the void setup, the ultrasonic sensor pins are notified to the Arduino board as output and input pins. Also, the PIN associated with the servo motor is notified to the library.

Afterward, an integer type variable is created to get the ultrasonic readings. Also, It is named “distance” and It includes the program to get the distance through the ultrasonic sensor. Also, this distance is converted to CM and returned.

Finally, the sensor takes the distance and checks it with an IF condition, if the value is less than 10cm, the servo motor is programmed 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

OK now, select the board and port. After, click the upload button.

Step 10

Lastly, connect the phone batteries and power up the Arduino board. Then, you can test this project. The full video guide is below. So, we hope to see you in the next project. Have a good day.

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

Similar Posts

Leave a Reply

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