Diy smart dustbin using Arduino

DIY Smart Dustbin with Arduino & Ultrasonic Sensor – Easy Robotics Project for Kids | MakeMindz
🖐️

DIY Smart Dustbin with Arduino

Wave your hand and the lid opens by itself! A red light tells you when the bin is full. Let's build a real robot that keeps our planet clean. 🌍

⏱ 90 minutes🎂 Ages 9–14⭐ Beginner💰 About ₹900

What Will We Make?

An automatic dustbin using sensors and a servo motor – a great beginner robotics project.

🦇 How does it work? The ultrasonic sensor sends out a sound too high for us to hear. The sound bounces off your hand and comes back. The Arduino times the trip, works out the distance, and tells the servo motor to lift the lid. A second sensor inside looks at the trash pile. When trash gets close to the top, the red LED lights up and a buzzer beeps!
👋

Sensor 1: Hand detector

Sits at the front. Opens the lid when your hand is within 20 cm.

🗑️

Sensor 2: Fullness checker

Faces down inside the lid. Measures how high the trash is.

💡

LEDs and buzzer

Green means ready. Red plus beep means please empty me!

Parts You Need

Ask a grown-up to help you shop. Everything is easy to find online.

🧠

Arduino Uno ×1

The brain of our robot.

📡

HC-SR04 ultrasonic ×2

The robot's "eyes".

⚙️

SG90 servo motor ×1

Moves the lid up and down.

🟢

Green + red LED

Status lights, one of each.

🔔

Active buzzer ×1

Beeps when the bin is full.

🔌

220Ω resistors ×2

Protect the LEDs.

🍞

Breadboard + jumper wires

No soldering needed!

📦

Small box or bin + tape

Use a clean plastic tub or cardboard box with a lid.

Circuit Diagram

Follow the colours. Red wires are power, black wires are ground.

Arduino Uno D9D10D7D85VGND D6D4D5D3 Sensor 1TRIG D9 · ECHO D10 Sensor 2TRIG D7 · ECHO D8 VCC (both) ← 5VGND (both) ← GND Servo signal Green LED Red LED Buzzer + Servo red → 5V, brown → GND LEDs via 220Ω, then GND Buzzer − → GND
PartPin on partArduino pin
Sensor 1 (hand)TRIG / ECHOD9 / D10
Sensor 2 (fullness)TRIG / ECHOD7 / D8
Both sensorsVCC / GND5V / GND
Servo SG90Signal (orange)D6
Servo SG90Red / Brown5V / GND
Green LEDLong leg through 220ΩD4 (short leg to GND)
Red LEDLong leg through 220ΩD5 (short leg to GND)
Buzzer+ / −D3 / GND

Step-by-Step Instructions

1

Prepare your dustbin

Take a small box or tub with a lid. Fix the servo motor beside the back edge of the lid using strong tape or hot glue (ask an adult). Tape a craft stick from the servo arm to the lid, so when the arm turns the lid lifts.

💡 Test by hand: the lid should lift smoothly with no sticking.
2

Place the sensors

Stick Sensor 1 on the front of the bin at hand height, looking outward. Tape Sensor 2 under the lid, looking down at the trash inside.

3

Wire power first

Connect Arduino 5V to the breadboard red rail and GND to the blue rail. Every part shares these two rails.

⚠️ Keep the USB cable unplugged while wiring.
4

Connect the parts

Use the wiring table above. Put each LED's long leg toward the resistor. Double-check TRIG and ECHO are not swapped.

5

Upload the code

Install the free Arduino IDE, plug in the USB cable, choose Tools → Board → Arduino Uno, paste the code below and press Upload ➜.

6

Test and tune

Wave your hand 10 cm from Sensor 1. The lid should open, wait 3 seconds, then close. Now hold a paper 5 cm below Sensor 2 – the red LED and buzzer switch on!

🎉 Decorate your bin with stickers and give it a cool name.

The Arduino Code

Every line has a comment, so you can learn as you go.

#include <Servo.h>   // library to control the servo

Servo lid;                // our lid motor

// ---- Pin numbers ----
const int trigHand = 9,  echoHand = 10;  // front sensor
const int trigBin  = 7,  echoBin  = 8;   // inside sensor
const int servoPin = 6, greenLed = 4, redLed = 5, buzzer = 3;

const int HAND_CM = 20;   // open lid if hand is closer than this
const int FULL_CM = 8;    // bin is full if trash is closer than this

// Measure distance in centimetres
long readCm(int trig, int echo) {
  digitalWrite(trig, LOW);  delayMicroseconds(2);
  digitalWrite(trig, HIGH); delayMicroseconds(10);   // send sound pulse
  digitalWrite(trig, LOW);
  long time = pulseIn(echo, HIGH, 30000);        // wait for echo
  if (time == 0) return 999;                    // nothing found
  return time * 0.034 / 2;                     // sound speed maths
}

void setup() {
  pinMode(trigHand, OUTPUT); pinMode(echoHand, INPUT);
  pinMode(trigBin, OUTPUT);  pinMode(echoBin, INPUT);
  pinMode(greenLed, OUTPUT); pinMode(redLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  lid.attach(servoPin);
  lid.write(0);                 // lid starts closed
}

void loop() {
  long hand = readCm(trigHand, echoHand);

  if (hand < HAND_CM) {           // someone is near!
    lid.write(90);                // open lid
    delay(3000);                  // keep open 3 seconds
    lid.write(0);                 // close lid
    delay(800);                   // let it settle
  }

  long trash = readCm(trigBin, echoBin);   // check fullness (lid closed)

  if (trash < FULL_CM) {          // bin is FULL
    digitalWrite(redLed, HIGH);  digitalWrite(greenLed, LOW);
    tone(buzzer, 1000, 200);      // short beep
  } else {                        // bin has space
    digitalWrite(redLed, LOW);   digitalWrite(greenLed, HIGH);
  }
  delay(200);
}
🎯 Try these tweaks: change HAND_CM to make the sensor more or less sensitive, change delay(3000) for longer open time, or change write(90) to write(120) for a wider lid.

Fix-It Corner 🔧

😴

Lid never opens

Check the servo signal wire is on D6 and the sensor's TRIG and ECHO are not swapped.

🎲

Lid jitters

Power dip. Use a fresh USB cable or a 4×AA battery pack for the servo, sharing GND with the Arduino.

🔴

Red LED always on

Sensor 2 sees the lid or a wall. Aim it straight down and increase the mounting height, or lower FULL_CM.

💡

LED not glowing

Flip it around. The long leg goes toward the Arduino pin.

Upgrade Ideas 🚀

📱

Bluetooth alerts

Add an HC-05 module to send "Bin Full" to your phone.

🖥️

LCD display

Show the fill level as a percentage.

☀️

Solar power

Charge a battery pack with a small solar panel.

♻️

Two-bin sorter

Build separate wet and dry waste bins.

Frequently Asked Questions

Which sensor does a smart dustbin use?

An HC-SR04 ultrasonic sensor. It measures distance with sound waves, just like a bat does.

Can I use only one sensor?

Yes! Remove the second sensor, red LED and buzzer for a simpler "open-lid only" version, then add them later.

Is this project safe for kids?

Yes. It runs on 5V from USB. Kids aged 9 to 14 should build it with an adult nearby, especially when using hot glue or scissors.

What will I learn?

How sensors, motors and code work together, plus how to read distances, control a servo and use if/else decisions.

Made with 💚 by MakeMindz · Learn, build and create robots! · makemindz.com

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
★★★★★ Young inventors love it!
🖨️
3D Print
All parts
⚡
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 ₹300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
★★★★★ Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 ₹200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course