top of page

Arduino Based Floor Cleaning Robot using Ultrasonic Sensor

Businesswomen Walking in Hallway

Automatic floor cleaners are nothing new, but they all share a common problem. They all are too expensive for what they do. Today, we will make a Automatic Home cleaning Robot that only costs a small fraction of the ones in the market. This Robot can detect the obstacles & objects in front of it and can continue moving, avoiding the obstacles, until the whole room is cleaned. It has a small brush attached to it to clean the floor


Component Required:

  1. Arduino UNO R3.
  2. Ultrasonic Sensor.
  3. Arduino Motor Driver shield.
  4. Wheel Drive Robot Chassis.
  5. Computer to Program the Arduino.
  6. Battery for the Motors.
  7. A Power Bank To Power The Arduino
  8. A Shoe Brush.
  9. A Scotch Brite Scrub Pad.

Assembly of Floor Cleaner Robot:

Mount the Arduino on the chassis. Make sure you don’t short circuit anything in case your chassis is made of metal. It is a good idea to get a box for the Arduino and the motor controller shield. Secure the motors with the wheels and chassis using screws. Your chassis should have options to do this from the factory, but if it doesn't, you can improvise a different solution. Epoxy isn’t a bad idea. Mount the shoe brush on the front of the chassis. We used a combination of M-Seal epoxy and drilled screws for this, though you can use any other solution that might be easier for you. Mount the Scotch Brite scrub pad behind the brush. We used a shaft going across the chassis that holds it in play, though this is improvisable as well. A spring loaded shaft can be used to accompany it. Mount the batteries (or cables on the back of the chassis). Epoxy or a battery holder are good ways to do this. Hot glue isn’t bad either.


Wiring and Connections:

Circuit for this Automatic Home Cleaning Robot is very simple. Connect the Ultrasonic sensor to the Arduino as mentioned below and place the Motor Driver shield on to the Arduino like any other shield.



The Trig pin of Ultrasonic is connected to the 12th pin on the Arduino, the Echo pin is connected to the 13th pin, the voltage pin to the 5V pin and the Ground pin to the ground pin. The Echo pin and the Trig pin allow the Arduino to communicate with the sensor. Power is delivered to the sensor through the voltage and Ground pins, and the Trig and Echo pins allow it to send and receive data with the Arduino.


The motor shield should have at least 2 outputs, and they should be connected to your 2 motors. Normally, these outputs are labelled “M1” and “M2” or “Motor 1” and “Motor 2”. Wire your batteries and power bank up to the motor shield and Arduino respectively. Do not cross connect them. Your motor shield should have an input channel. If you’re using wires, connect them to AC adapters.



Code

#include <AFMotor.h>

#define trigPin 12

#define echoPin 13

AF_DCMotor motor1(1,MOTOR12_64KHZ);

AF_DCMotor motor2(2, MOTOR12_8KHZ);

void setup() {

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

}

void loop() {

long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance < 20) {

motor1.setSpeed(255);

motor2.setSpeed(0);

motor1.run(BACKWARD);

motor2.run(BACKWARD);

delay(2000); //CHANGE THIS ACCORDING TO HOW THE ROBOT TURNS.

}

else {

motor1.setSpeed(160); //CHANGE THIS ACCORDING TO HOW FAST YOUR ROBOT SHOULD GO.

motor2.setSpeed(160); //CHANGE THIS TO THE SAME VALUE AS YOU PUT IN ABOVE.

motor1.run(FORWARD);

motor2.run(FORWARD);

}

}



Reference


https://www.academia.edu/39048005/MOBILE_AIDED_AUTOMATIC_ARDUINO_BASED_FLOOR_CLEANING_ROBOT_USING_ULTRASONIC_SENSOR_i

https://circuitdigest.com/microcontroller-projects/arduino-floor-cleaning-robot

bottom of page