Site icon Circuit Ideas for You

Touchless Dustbin Circuit using Arduino Uno and Ultrasonic Sensor

This Touchless Dustbin Circuit using an Arduino Uno and Ultrasonic Sensor is a simple and useful mini project; people also call it a smart dustbin or an automatic dustbin because it opens and closes automatically without touch.

In normal dustbin we have to touch lid by hand which is not hygienic, but in smart dustbin the lid opens automatically when person comes near.

Also, the circuit uses an Arduino, an ultrasonic sensor and a servo motor; we can use it in homes, offices, hospitals and public places.

Arduino Code:

#include <Servo.h>

Servo servoMotor;  
int trigPin = 9;   
int echoPin = 10;  
long duration;     
int distance;      

void setup() {
  servoMotor.attach(6);       // Servo signal pin connected to D6
  pinMode(trigPin, OUTPUT);   // Trig pin of ultrasonic sensor
  pinMode(echoPin, INPUT);    // Echo pin of ultrasonic sensor
  servoMotor.write(0);        // Initial position, lid closed
  delay(1000);
  Serial.begin(9600);         // For debugging
}

void loop() {
  // Send ultrasonic trigger pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read echo time
  duration = pulseIn(echoPin, HIGH);

  // Convert time into distance (cm)
  distance = duration * 0.034 / 2;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  // Check if object is near (less than 10 cm)
  if (distance < 10) {
    servoMotor.write(90);   // Open lid
    delay(3000);            // Wait for 3 seconds
    servoMotor.write(0);    // Close lid
  }
}

Code Explanation:

Circuit Working:

Touchless Dustbin Circuit Diagram using Arduino Uno and Ultrasonic Sensor

Parts List:

ComponentsQuantity
Arduino UNO1
Servo Motor1
Ultrasonic Sensor 1
9V Battery1

Arduino UNO is the main controller and this power supply also run servo and sensor and the ultrasonic sensor sense distance of object.

When hand or any object comes in front of dustbin within set range then Arduino receive signal, then Arduino send command to servo motor.

After that, servo motor rotates and open the dustbin lid and after some seconds servo again rotate back and closes the lid.

A 9V battery powers the circuit.

Pin connections of Ultrasonic sensor, Servo motor and 9V battery:

Ultrasonic sensor has 4 pins.

Servo motor has 3 wires.

Also, 9V battery connect to Arduino Vin and GND pin.

Formulas:

Formula for distance = (Echo Time in microsecond × 0.034) / 2

Example: If echo time is 600 microsecond then distance = (600 × 0.034) / 2 = 10.2 cm approx.

If distance < 10 cm then dustbin lid gets open.

Conclusion:

To conclude, this Touchless Dustbin Circuit using an Arduino Uno and Ultrasonic Sensor is a simple and useful project, it offers a low-cost, automatic solution that helps keep the dustbin hygienic.

Therefore, there is no need to touch lid by hand, moreover, the circuit is good for school, home, office and hospital; also with bigger servo or metal frame we can work for large dustbin also.

Exit mobile version