Ghana-Kumasi

Smart Dust Bin: Automatic Wet and Dry Trash Sorting
Smart Dust Bin: Automatic Wet and Dry Trash Sorting
This project teaches students how to build a Smart Dust Bin using Arduino, which can automatically detect trash, identify whether it is wet or dry, and direct it to the correct compartment. It integrates an ultrasonic sensor, soil moisture sensor, and servo motor to create a fully functional, automated bin.
Project Overview
The smart dust bin system works as follows:
- Trash Detection
- An ultrasonic sensor senses when trash is near the lid.
- Trash Type Detection
- A soil moisture sensor checks whether the trash is wet or dry.
- Automatic Sorting
- A servo motor opens the lid in the correct direction:
- Left → Dry trash
- Right → Wet trash
- A servo motor opens the lid in the correct direction:
- Return Lid
- After the trash is deposited, the servo returns the lid to the center.
This project introduces students to Arduino programming, sensors, and actuator control, while encouraging practical applications in environmental management.
Components Required
| Component | Quantity | Notes |
|---|---|---|
| Arduino Uno | 1 | Can also use Nano or Mega |
| HC-SR04 Ultrasonic Sensor | 1 | Measures distance to trash |
| Analog Soil Moisture Sensor | 1 | Detects wet/dry trash |
| 9G Servo Motor | 1 | Controls lid movement |
| Jumper Wires | ~10 | Male-to-female recommended |
| Breadboard | 1 | Optional for easy connections |
| 5V Power Source | 1 | Arduino 5V or external supply |
Pin Connections
| Arduino Pin | Component | Function |
|---|---|---|
| D2 | HC-SR04 Echo | Receives ultrasonic signal |
| D3 | HC-SR04 Trig | Sends ultrasonic pulse |
| D4 | Servo Signal | Controls servo lid |
| A3 | Soil Moisture AO | Analog output for wet/dry detection |
| 5V | Sensor VCC | Power for sensor and servo |
| GND | Sensor GND | Common ground |
Tip: Connect all grounds together to avoid erratic sensor readings.
Working Principle
- Ultrasonic Sensor
- Sends a pulse and measures the time it takes to reflect back.
- If an object is within
15 cm, it triggers moisture detection.
- Soil Moisture Sensor
- Reads analog values:
- Wet trash → lower analog value
- Dry trash → higher analog value
- Threshold (
wetThreshold) separates wet and dry.
- Reads analog values:
- Servo Motor
- Moves to
30°for dry trash (left) and150°for wet trash (right). - Waits 2 seconds for trash to fall, then returns to
90°(center).
- Moves to
Full Arduino Code
#include <Arduino.h>
#include <NewPing.h>
#include <Servo.h>
// ---------------- PIN DEFINITIONS ----------------
#define TRIG_PIN 3
#define ECHO_PIN 2
#define SERVO_PIN 4
#define SOIL_PIN A3 // Analog soil sensor pin
// ---------------- OBJECTS ----------------
NewPing ultrasonic(TRIG_PIN, ECHO_PIN, 200); // max distance 200 cm
Servo lidServo;
// ---------------- SERVO POSITIONS ----------------
int centerPos = 90; // Lid closed
int dryPos = 30; // Left → Dry trash
int wetPos = 150; // Right → Wet trash
// ---------------- THRESHOLDS ----------------
int detectDistance = 15; // cm, object detection range
int wetThreshold = 500; // adjust after testing
void setup() {
Serial.begin(9600);
lidServo.attach(SERVO_PIN);
lidServo.write(centerPos); // start with lid closed
pinMode(SOIL_PIN, INPUT);
Serial.println("Smart Dust Bin System Started");
}
void loop() {
// Step 1: Detect object with ultrasonic sensor
int distance = ultrasonic.ping_cm();
if (distance > 0 && distance <= detectDistance) { // Trash detected
// Step 2: Check soil moisture
int moisture = analogRead(SOIL_PIN);
Serial.print("Distance: ");
Serial.print(distance);
Serial.print(" cm | Moisture: ");
Serial.println(moisture);
// Step 3: Decide wet or dry and move servo
if (moisture < wetThreshold) {
// Wet trash → Right
Serial.println("WET TRASH → Moving servo RIGHT");
lidServo.write(wetPos);
} else {
// Dry trash → Left
Serial.println("DRY TRASH → Moving servo LEFT");
lidServo.write(dryPos);
}
// Step 4: Keep lid open for trash to fall
delay(2000);
// Step 5: Return lid to center
lidServo.write(centerPos);
delay(1000);
}
delay(300); // Small delay before next reading
}
Testing and Calibration
- Ultrasonic Sensor
- Place your hand near the sensor.
- Serial monitor should display the distance.
- Soil Moisture Sensor
- Place in dry trash → note analog value
- Place in wet trash → note analog value
- Adjust
wetThresholdin code according to readings.
- Servo Motor
- Ensure it moves smoothly left for dry and right for wet trash.
- Adjust
dryPosandwetPosif lid doesn’t align with compartments.
Tips for Students
- Keep sensor pins clean and dry for accurate readings.
- Use external power for servo if it jitters.
- Test with different types of trash to ensure reliability.
- Optionally, add LED indicators to show wet/dry trash.
Learning Outcomes
Students who complete this project will:
- Understand how to integrate multiple sensors with Arduino.
- Learn to control servo motors programmatically.
- Gain experience building smart mechatronic systems.
- Understand practical applications in waste management automation.
EMMANUEL ADU DONKOR
Am Emmanuel ADU Donkor CEO of LEARN STEM AFRICA