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! 🗑️✨
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!
Step-by-Step Instructions 🛠️
Follow each step carefully. Ask a grown-up to help with any tricky parts!
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).
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.
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.
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.
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!
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!
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.
Circuit Diagram 🔌
Here's how everything connects together. Match the colours when wiring!
| Component | Pin on Component | Arduino Pin | Wire Colour |
|---|---|---|---|
| HC-SR04 Ultrasonic | VCC | 5V | 🔴 Red |
| HC-SR04 Ultrasonic | GND | GND | ⚫ Black |
| HC-SR04 Ultrasonic | TRIG | D9 | 🟡 Yellow |
| HC-SR04 Ultrasonic | ECHO | D10 | 🔵 Blue |
| L298N Motor Driver | IN1 | D2 | 🟠 Orange |
| L298N Motor Driver | IN2 | D3 | 🟠 Orange |
| L298N Motor Driver | IN3 | D4 | 🟠 Orange |
| L298N Motor Driver | IN4 | D5 | 🟠 Orange |
| L298N Motor Driver | ENA | D6 | ⚪ White |
| L298N Motor Driver | ENB | D7 | ⚪ White |
| Servo Motor 1 (Claw) | Signal | D11 | 🟣 Purple |
| Servo Motor 2 (Arm) | Signal | D12 | 🟣 Purple |
| Green LED | Anode (+) | D13 | 🟢 Green |
| Red LED | Anode (+) | 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 - 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!

Comments
Post a Comment