Build Your Own Garbage Collection Robot!

Build Your Own Garbage Collection Robot! | Kids Robotics Project
🌍 STEM Robotics Project

Build Your Own
Garbage Collection Robot!

Meet RoboSweep — a smart robot that finds trash and collects it all by itself. Let's build it together! 🗑️✨

⏱️ 3–4 Hours
🎓 Age 10+
💰 Budget-Friendly
Beginner Level

How Does RoboSweep Work? 🤔

RoboSweep uses sensors like a robot's "eyes" and a tiny brain (Arduino) to think and move. Here's its superpower sequence:

📡

Sense

Ultrasonic sensor detects objects up to 30cm away — just like a bat using echolocation!

🧠

Think

Arduino (the robot's brain) decides: "Is something close? Then stop and collect!"

🦾

Grab

A servo-powered claw arm swings down to scoop up the garbage. Grab it! 💪

🚗

Move

DC motors spin wheels to drive around and look for more trash to collect!

What Do You Need? 🧰

Gather these parts before you start. You can find most of them at an electronics shop or order online!

🖥️ Arduino Uno R3 ×1
📡 HC-SR04 Ultrasonic Sensor ×1
⚙️ SG90 Micro Servo Motor ×2
🔧 L298N Motor Driver Module ×1
🛞 DC Gear Motors + Wheels ×2
🔋 9V Battery + Connector ×1
🔌 Jumper Wires (M-M, M-F) ×30
🧩 Breadboard (mini) ×1
🚗 Robot Chassis Kit (acrylic) ×1
🤏 Mini Gripper Claw Kit ×1
🔩 M3 Screws, Nuts, Spacers ×1 set
💡 LED (green + red) ×2

Step-by-Step Instructions 🛠️

Follow each step carefully. Ask a grown-up to help with any tricky parts!

01
🚗

Build the Robot Chassis

Open your acrylic chassis kit. Attach the two DC gear motors to the bottom platform using M3 screws. Snap the wheels onto the motor shafts. Add the small caster wheel at the front (it spins freely to help balance the robot).

💡 Tip: Make sure the motors point outward on each side — like a real car's axles!
02
📡

Mount the Ultrasonic Sensor

Fix the HC-SR04 sensor to the front of the chassis using double-sided tape or a small bracket. The two silver cylinders (the "eyes") must face forward. Connect 4 jumper wires: VCC → 5V, GND → GND, TRIG → Pin 9, ECHO → Pin 10 on Arduino.

💡 Tip: Think of TRIG as the sensor sending a sound wave, and ECHO as listening for the bounce back!
03
🔧

Wire the Motor Driver (L298N)

Place the L298N module on the upper deck. Connect: IN1 → Pin 2, IN2 → Pin 3, IN3 → Pin 4, IN4 → Pin 5 on Arduino. Connect ENA and ENB to Pins 6 and 7. Wire the left motor to OUT1/OUT2 and the right motor to OUT3/OUT4. Power the L298N with the 9V battery.

💡 Tip: The L298N is like a translator — Arduino speaks softly, and the L298N speaks loudly to the motors!
04
🤏

Attach the Gripper Claw

Assemble the mini gripper kit. Attach Servo 1 (controls opening/closing the claw) inside the gripper. Attach Servo 2 (lifts the arm up and down) to the robot's front mounting bracket. Connect both servo signal wires: Servo 1 → Pin 11, Servo 2 → Pin 12. Power servos from 5V pin on Arduino.

💡 Tip: Test each servo BEFORE mounting — use the sweep example in Arduino IDE!
05
💡

Add Status LEDs

Connect a GREEN LED (with 220Ω resistor) to Pin 13 → GND. Connect a RED LED (with 220Ω resistor) to Pin 8 → GND. Green blinks when the robot is searching; Red lights up when it's collecting garbage!

💡 Tip: Always add a resistor with LEDs — without it, the LED can burn out instantly!
06
🔋

Connect Power & Upload Code

Connect the 9V battery to the L298N's power input. Plug Arduino into your computer via USB. Open Arduino IDE, paste the code (below), select "Arduino Uno" under Tools → Board, then click Upload (the arrow button). Once done, disconnect USB and power up with the battery!

💡 Tip: Download Arduino IDE free from arduino.cc — it's the app you use to write code for Arduino!
07
🎉

Test RoboSweep!

Place some small crumpled paper balls on the floor (pretend garbage!). Power on your robot and watch it cruise around, detect objects, open its claw, and grab them! If it doesn't work right, go back and check all wiring connections.

💡 Tip: Use the Serial Monitor (Ctrl+Shift+M) in Arduino IDE to see sensor readings while debugging!

Circuit Diagram 🔌

Here's how everything connects together. Match the colours when wiring!

ARDUINO UNO 5V ● GND ● D2 ● D3 ● D4 ● D5 ● D6 ● D7 ● ●D9 D10● D11● D12● D8● D13● HC-SR04 VCC GND TRIG ECHO 5V (red) → D9 → D10 L298N Motor Driver IN1 IN2 IN3 IN4 ENA ENB OUT1/2 OUT3/4 +12V (Battery) IN1-4 → D2-5 Motor L Motor R OUT1/2 OUT3/4 SERVO 1 Claw Open/Close SIG → D11 SERVO 2 Arm Up/Down SIG → D12 D11, D12 LEDs 🟢 D13 (search) 🔴 D8 (collect) 9V Battery → L298N VCC GND → Common — Red: Power (5V/VCC) — Grey: Ground (GND) — Yellow: Signal — Cyan: Data
Component Pin on Component Arduino Pin Wire Colour
HC-SR04 UltrasonicVCC5V🔴 Red
HC-SR04 UltrasonicGNDGND⚫ Black
HC-SR04 UltrasonicTRIGD9🟡 Yellow
HC-SR04 UltrasonicECHOD10🔵 Blue
L298N Motor DriverIN1D2🟠 Orange
L298N Motor DriverIN2D3🟠 Orange
L298N Motor DriverIN3D4🟠 Orange
L298N Motor DriverIN4D5🟠 Orange
L298N Motor DriverENAD6⚪ White
L298N Motor DriverENBD7⚪ White
Servo Motor 1 (Claw)SignalD11🟣 Purple
Servo Motor 2 (Arm)SignalD12🟣 Purple
Green LEDAnode (+)D13🟢 Green
Red LEDAnode (+)D8🔴 Red

The Robot's Brain 🧠

Copy this code into Arduino IDE and upload it to your Arduino Uno. Every line is explained with comments!

RoboSweep.ino
// =====================================================
//  RoboSweep - Intelligent Garbage Collection Rover
// For Arduino Uno | Kids Robotics Project
// =====================================================

#include <Servo.h>     // Library to control servo motors

// ── Pin Definitions ──────────────────────────────────
const int TRIG_PIN  = 9;    // Ultrasonic sensor: sends sound wave
const int ECHO_PIN  = 10;   // Ultrasonic sensor: listens for bounce

const int IN1 = 2;          // L298N: Left motor direction
const int IN2 = 3;
const int IN3 = 4;          // L298N: Right motor direction
const int IN4 = 5;
const int ENA = 6;          // Left motor speed (PWM)
const int ENB = 7;          // Right motor speed (PWM)

const int LED_GREEN = 13;   // Green LED = searching for trash
const int LED_RED   = 8;    // Red LED   = collecting trash

Servo clawServo;             // Servo 1: opens and closes claw
Servo armServo;              // Servo 2: lifts and lowers arm

const int DETECT_DIST = 20; // cm — how close before robot grabs
const int MOTOR_SPEED = 180;// Motor speed (0=stopped, 255=full)

// ── Setup (runs once when powered on) ────────────────
void setup() {
  // Ultrasonic sensor pins
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);

  // Motor driver pins
  pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT);

  // LED pins
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_RED,   OUTPUT);

  // Attach servos to their pins
  clawServo.attach(11);
  armServo.attach(12);

  // Start with arm up, claw open
  armServo.write(0);    // Arm raised
  clawServo.write(80);  // Claw open

  Serial.begin(9600);   // Start serial (for debugging)
  Serial.println("🤖 RoboSweep Online! Ready to collect garbage!");
}

// ── Main Loop (repeats forever) ───────────────────────
void loop() {
  long distance = getDistance();  // Measure distance

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

  if (distance > 0 && distance < DETECT_DIST) {
    // 🗑️ GARBAGE DETECTED! Stop and collect.
    stopMotors();
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_RED, HIGH);   // Red LED ON

    Serial.println("🗑️ Garbage found! Collecting...");
    collectGarbage();               // Run grab sequence

    digitalWrite(LED_RED, LOW);
    delay(500);
    turnRight();                    // Turn to look for more
    delay(600);

  } else {
    // 🔍 No garbage nearby — keep moving forward
    moveForward();
    digitalWrite(LED_RED, LOW);

    // Blink green LED while searching
    digitalWrite(LED_GREEN, HIGH);
    delay(200);
    digitalWrite(LED_GREEN, LOW);
    delay(200);
  }
}

// ── Measure Distance with Ultrasonic Sensor ──────────
long getDistance() {
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);

  digitalWrite(TRIG_PIN, HIGH);   // Send sound pulse
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  long duration = pulseIn(ECHO_PIN, HIGH); // Measure time
  return duration * 0.034 / 2;   // Convert to cm
}

// ── Collect Garbage Sequence ──────────────────────────
void collectGarbage() {
  armServo.write(90);   // Lower arm down
  delay(700);

  clawServo.write(10);  // Close claw — GRAB! 🤏
  delay(700);

  armServo.write(0);    // Lift arm up with garbage
  delay(700);

  Serial.println("✅ Garbage collected! Great job RoboSweep!");
  delay(1000);

  clawServo.write(80);  // Open claw — drop in bin
  delay(500);
}

// ── Motor Control Functions ───────────────────────────
void moveForward() {
  analogWrite(ENA, MOTOR_SPEED);
  analogWrite(ENB, MOTOR_SPEED);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);  // Left forward
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);  // Right forward
}

void stopMotors() {
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

void turnRight() {
  analogWrite(ENA, MOTOR_SPEED);
  analogWrite(ENB, MOTOR_SPEED);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);   // Left: forward
  digitalWrite(IN3, LOW);  digitalWrite(IN4, HIGH);  // Right: backward
}

📡 getDistance()

Sends a tiny sound pulse and times how long it takes to bounce back. Longer time = farther object. Like yelling in a cave!

🤏 collectGarbage()

Lowers the arm → closes the claw → lifts back up. It's like a claw machine at an arcade! 🕹️

🚗 moveForward()

Tells both motors to spin forward. Change MOTOR_SPEED (0–255) to make it go faster or slower!

🔄 loop()

The main brain! It keeps checking: "Is something close?" If yes → grab it! If no → keep moving and looking.

Stay Safe While Building 🦺

Building robots is super fun — but always follow these important safety rules!

👨‍👩‍👧

Adult Supervision

Always have a parent or teacher nearby, especially when using tools or soldering.

🔌

Power Off First

Always disconnect the battery before changing any wires. Never work on a powered circuit!

🔭

Check Your Wires

Short circuits can damage your Arduino. Double-check every connection before powering up.

🤗

Ask for Help

Stuck? That's normal! Ask a teacher, parent, or friend. Two heads are better than one! 🧠🧠

What Are You Learning? 📚

This project teaches real engineering skills used by scientists and engineers every day!

📡

Ultrasonics

Sound waves travel, bounce off objects, and return. Bats, submarines, and this robot all use this trick!

Electronics

You're learning to build real circuits — the same skill behind every phone, computer, and gadget!

💻

Programming

C++ code is what professionals use at NASA and Tesla. You're writing it too — how cool is that?!

♻️

Environment

Robots like yours could help clean parks and oceans! You're solving a real-world problem! 🌍

🤖

Robotics & AI

Decision-making code (if/else) is the foundation of how all AI systems think and respond to the world.

🔧

Mechanical Design

Building the chassis and claw teaches you about levers, gears, and how machines move things!

Want to Make RoboSweep Even Smarter? 🧠✨

Once your basic robot works, try these awesome upgrades!

🔊

Add a Buzzer

Connect a piezo buzzer to play a sound when garbage is detected. Beep beep! 📢

📱

Bluetooth Control

Add an HC-05 Bluetooth module so you can also drive the robot with your phone!

🗺️

Map the Room

Add a second sensor pointing sideways to detect walls and map a room automatically!

🌡️

Garbage Sorter

Add a colour sensor to sort garbage by colour — put green stuff in one bin, red in another!

An Intelligent Garbage Collection Rover — Kids Robotics Project

Built with ❤️ for young engineers everywhere. Keep building, keep learning! 🚀

Tags: Arduino Project | Robotics for Kids | STEM | Garbage Robot | HC-SR04 | Servo Motor | L298N | Kids Engineering

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