Build Your Own Smart Floor Cleaning Robot!

Build Your Own Smart Floor Cleaning Robot! | Kids Arduino STEM Project

Build Your Own Smart Floor Cleaning Robot!

A fun robotics project for curious kids — ages 10 and up!
Learn circuits, coding & engineering.

🔧 Arduino UNO 🔋 Easy to Build ⏱️ 3–4 Hours 🎓 STEM Project 💰 Under ₹1500
Hey young engineer! 👋 Ever wished your robot could clean your room for you? Today, we're going to build one from scratch! This smart little robot uses sensors to detect walls and furniture, then automatically changes direction — just like a real Roomba! You'll learn electronics, circuits, and coding all in one project. Let's gooo! 🚀

🛒 What You Need (Parts List)

🧠
Arduino UNO
The robot's brain — runs your code!
× 1
⚙️
DC Motors + Wheels
Makes the robot move around
× 2 motors, × 2 wheels
🎛️
L298N Motor Driver
Tells motors how fast & which way
× 1
📡
HC-SR04 Ultrasonic Sensor
Detects walls like a bat using sound!
× 2
🔋
9V Battery + Holder
Powers the whole robot
× 1
🧹
Small Brush / Sponge
The actual cleaning part!
× 1
📟
Breadboard + Jumper Wires
Connects all the parts together
assorted
📦
Cardboard / Acrylic Chassis
The body of your robot
× 1 base plate
🔩
Caster Wheel
Front support wheel for balance
× 1
🖥️
USB Cable (Type B)
To upload code from your computer
× 1

🔌 Circuit Wiring Guide

⚡ Arduino UNO → L298N Motor Driver
Arduino PinL298N PinPurpose
D3 (PWM)ENALeft motor speed
D4IN1Left motor direction A
D5IN2Left motor direction B
D6 (PWM)ENBRight motor speed
D7IN3Right motor direction A
D8IN4Right motor direction B
GNDGNDCommon ground
9V Battery12V INMotor power supply

📡 HC-SR04 Ultrasonic Sensors
Arduino PinSensor PinSensor
D9TRIGFront sensor
D10ECHOFront sensor
D11TRIGRight side sensor
D12ECHORight side sensor
5VVCCBoth sensors
GNDGNDBoth sensors

🗺️ Circuit Diagram

🔌 How Everything Connects
Smart Robot Circuit Diagram Arduino UNO connects to L298N Motor Driver, two HC-SR04 sensors, and a 9V battery. Motors connect to the driver output. Arduino UNO 🧠 The Brain Pins D3–D12 · GND · 5V L298N Driver Motor Driver ⚙️ Speed & Direction HC-SR04 Front 📡 Front Obstacle Sensor HC-SR04 Right 📡 Right Side Sensor DC Motors ×2 🛞 Left & Right Wheels 9V Battery 🔋 Power Source 🤖 Your Robot! 5V power 9V power D3–D8 OUT1–4 D9, D10 D11, D12

🔨 Step-by-Step Build Instructions

  1. 🗂️ Prepare Your Chassis (Body)

    Cut a 20 cm × 15 cm piece of cardboard or acrylic sheet. This is your robot's body! Make two holes on each side for the motor shafts. Draw a grid on top so you know where to place each part.

    💡 Ask a grown-up to help with cutting. Use a ruler for straight edges!
  2. ⚙️ Mount the DC Motors

    Attach both DC motors to the sides of the chassis using hot glue or zip ties. The motor shafts should stick out through the holes. Push the wheels onto the motor shafts firmly. Add a small caster wheel at the front for balance!

    💡 Make sure both motors face the same direction so the robot goes straight!
  3. 🎛️ Install the Motor Driver (L298N)

    Glue the L298N motor driver board in the center of the chassis. Connect the left motor wires to OUT1 and OUT2 terminals. Connect the right motor wires to OUT3 and OUT4 terminals. Use a screwdriver to tighten the terminal screws.

    💡 Red wire = positive (+), Black wire = negative (−). Don't mix them up!
  4. 📡 Attach the Ultrasonic Sensors

    Mount the first HC-SR04 sensor at the front of the robot pointing forward. Mount the second sensor on the right side pointing sideways. Use hot glue or a small bracket. These sensors detect objects like a bat using sound waves!

    💡 The two circles on the sensor are like little ears — one sends sound, one receives it!
  5. 🧠 Connect the Arduino

    Place the Arduino UNO on the chassis. Using jumper wires, connect it to the motor driver (pins D3–D8) and both sensors (pins D9–D12) following the wiring table above. Use the breadboard for clean connections. Double-check every wire!

    💡 Use different colored wires: red for power, black for ground, blue/green for signals!
  6. 🧹 Add the Cleaning Brush

    Tape or glue a small brush, sponge, or microfiber cloth to the front-bottom of the robot. This is what cleans the floor! Make sure it touches the ground gently but doesn't stop the wheels from spinning.

    💡 Try a bottle brush cut in half for a really good cleaning effect!
  7. 💻 Upload the Code

    Connect your Arduino to a computer using a USB cable. Open the Arduino IDE app. Copy and paste the code below. Click the Upload button (the right arrow ➡️). Wait for "Done uploading!" to appear at the bottom.

    💡 Download Arduino IDE free from arduino.cc — it's the app you use to write robot code!
  8. 🔋 Power Up & Test!

    Disconnect the USB cable. Connect the 9V battery to the L298N power terminals. Turn it on and place the robot on the floor. Watch it go! It should move forward and turn when it detects an obstacle. Do a happy dance! 🎉

    💡 Test on a smooth floor first. Carpet might slow the wheels down!

💻 The Arduino Code

🤖 Smart Floor Cleaning Robot — Full Arduino Code
// ============================================
// Smart Floor Cleaning Robot for Kids 
// Works with: Arduino UNO + L298N + HC-SR04
// ============================================

// --- Motor Driver Pins ---
const int ENA = 3;   // Left motor speed (PWM)
const int IN1 = 4;   // Left motor direction A
const int IN2 = 5;   // Left motor direction B
const int ENB = 6;   // Right motor speed (PWM)
const int IN3 = 7;   // Right motor direction A
const int IN4 = 8;   // Right motor direction B

// --- Ultrasonic Sensor Pins ---
const int FRONT_TRIG = 9;
const int FRONT_ECHO = 10;
const int RIGHT_TRIG = 11;
const int RIGHT_ECHO = 12;

// --- Robot Settings ---
const int SPEED     = 180;  // Motor speed (0 to 255)
const int SAFE_DIST = 20;   // cm — turn if closer than this

// ============================================
// SETUP — runs ONCE when robot turns on
// ============================================
void setup() {
  // Motor driver pins → OUTPUT
  pinMode(ENA, OUTPUT);  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);  pinMode(ENB, OUTPUT);
  pinMode(IN3, OUTPUT);  pinMode(IN4, OUTPUT);

  // Sensor pins
  pinMode(FRONT_TRIG, OUTPUT);  pinMode(FRONT_ECHO, INPUT);
  pinMode(RIGHT_TRIG, OUTPUT);  pinMode(RIGHT_ECHO, INPUT);

  Serial.begin(9600);
  Serial.println("Robot is awake! Let's clean! 🤖");
}

// ============================================
// getDistance() — sends a sound pulse and
// measures how far away the object is
// ============================================
long getDistance(int trigPin, int echoPin) {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);   // Send sound pulse
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

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

// ============================================
// Movement functions
// ============================================
void moveForward() {
  analogWrite(ENA, SPEED);  analogWrite(ENB, SPEED);
  digitalWrite(IN1, HIGH);  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);  digitalWrite(IN4, LOW);
}

void turnLeft() {
  analogWrite(ENA, SPEED);  analogWrite(ENB, SPEED);
  digitalWrite(IN1, LOW);   digitalWrite(IN2, HIGH); // Left backward
  digitalWrite(IN3, HIGH);  digitalWrite(IN4, LOW);  // Right forward
  delay(500);  // Turn for half a second
}

void stopMotors() {
  digitalWrite(IN1, LOW);  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);  digitalWrite(IN4, LOW);
}

// ============================================
// LOOP — runs FOREVER while robot is on
// ============================================
void loop() {
  // Read distances from both sensors
  long frontDist = getDistance(FRONT_TRIG, FRONT_ECHO);
  long rightDist = getDistance(RIGHT_TRIG, RIGHT_ECHO);

  // Print to Serial Monitor (for debugging)
  Serial.print("Front: ");
  Serial.print(frontDist);
  Serial.print(" cm | Right: ");
  Serial.print(rightDist);
  Serial.println(" cm");

  // Decision time!
  if (frontDist < SAFE_DIST) {
    stopMotors();       // Something in front — STOP!
    delay(200);
    turnLeft();         // Turn away from obstacle
  } else {
    moveForward();      // Path is clear — keep cleaning!
  }

  delay(50); // Small pause before checking again
}

🔍 How Does It Work?

The robot uses a clever loop to keep your floors clean automatically — 20 times every second!

📡

1. Sense

The ultrasonic sensor sends out a sound wave and measures how long it takes to bounce back.

🧮

2. Calculate

The Arduino does math to turn the echo time into a distance in centimetres.

🤔

3. Decide

If something is closer than 20 cm, the code says "STOP and turn!" Otherwise, keep going!

⚙️

4. Act

The motor driver powers the wheels to go forward or turn, based on what the Arduino decided.

🧹

5. Clean

While rolling around, the brush at the front sweeps dust and dirt along the floor!

🔁

6. Repeat

The loop() function runs over and over so the robot never stops thinking or cleaning!

⚠️ Safety Tips for Young Engineers

Stay safe while building!

  • Always ask a parent or teacher before using hot glue guns or scissors
  • Never connect the battery while wiring — disconnect it first!
  • Don't touch the motor driver when powered on — it can get warm
  • Use USB power for testing your code before connecting the 9V battery
  • Keep the robot away from water — electronics and water don't mix!
  • Don't run the robot near stairs, table edges, or on wet floors
  • Always supervise younger siblings around the robot while it's running

🚀 Cool Upgrades to Try Next!

Level up your robot! 🎮

📱 Bluetooth Control

Add an HC-05 Bluetooth module so you can drive it with your phone!

🌡️ Dirt Sensor

Add an IR sensor to detect extra dusty spots and clean them twice!

🗺️ Room Mapping

Use an ESP32 to map the room and clean in neat rows like a real Roomba!

🔊 Sound Effects

Add a buzzer that beeps when the robot finds an obstacle — like a backing-up truck!

💡 RGB LED Lights

LEDs that change colour when the robot turns, stops, or finishes cleaning!

📦 Dustbin Compartment

Attach a small box at the back to collect all the swept dust automatically!

🤖 Built with curiosity & code  |  A STEM Kids Lab project  |  Happy building, young engineer! 🚀

Share your robot with the world! Use #KidsRoboticsProject

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