yadukrishnan n
Published

Automatic Floor Disinfecting Robot

Automatically avoid obstacles in a room and sweep the floor using disinfectant. Preferable in hospitals to maintain social distance.

IntermediateFull instructions provided10 hours2,315
Automatic Floor Disinfecting Robot

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Geared DC Motor, 12 V
Geared DC Motor, 12 V
×3
Rechargeable Battery, Lithium Ion
Rechargeable Battery, Lithium Ion
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering
Jumper Wire Kit, Multicolor
Jumper Wire Kit, Multicolor
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Schematics

Connect components as per the image.

Code

Automatic disinfecting robot code

Arduino
Use Arduino IDE to upload code to the Arduino Nano
#include <Servo.h> 

int servoPin = 8;
Servo Servo1; 

//Motor A
const int inputPin1  = 5;    // Pin 15 of L293D IC
const int inputPin2  = 4;    // Pin 10 of L293D IC
//Motor B
const int inputPin3  = 3;   // Pin  7 of L293D IC
const int inputPin4  = 2;   // Pin  2 of L293D IC
const int trigPin = 9;
const int echoPin = 10;

const int motorpin  = 6;   //Cleaning Motor
const int pumppin  = 7;   //water pump

// defines variables
long duration;
int distance;
long duration2;
int distanceleft;
int distanceright;


void setup() 
{
   Servo1.attach(servoPin); 
   Servo1.write(90);
    
    pinMode(inputPin1, OUTPUT);
    pinMode(inputPin2, OUTPUT);
    pinMode(inputPin3, OUTPUT);
    pinMode(inputPin4, OUTPUT); 
     
    pinMode(motorpin, OUTPUT);
    pinMode(pumppin, OUTPUT);
    
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}

void loop() 
{
  Servo1.write(90);
  delay(2000);
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
digitalWrite(motorpin, HIGH);
digitalWrite(pumppin, HIGH);

if(distance<=12)
{
 
  
    digitalWrite(inputPin1, LOW);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, LOW);
    digitalWrite(inputPin4, LOW);
    distanceright = lookright();
    distanceleft = lookleft();
  
 if(distanceright>distanceleft)
 {
    digitalWrite(inputPin1, HIGH);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, HIGH);
    digitalWrite(inputPin4,LOW);  //Reverse wheels
      
    delay(1000);
  
    digitalWrite(inputPin1, LOW);
    digitalWrite(inputPin2, HIGH);
    digitalWrite(inputPin3, HIGH);
    digitalWrite(inputPin4, LOW);  
    delay(700);                  //Turns right
    
    digitalWrite(inputPin1, LOW);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, LOW);
    digitalWrite(inputPin4, LOW); //stop turning
 }
 else
 {
  
    digitalWrite(inputPin1, HIGH);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, HIGH);
    digitalWrite(inputPin4,LOW);  //Reverse wheels
     
    delay(1000);
  
    digitalWrite(inputPin1, HIGH);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, LOW);
    digitalWrite(inputPin4, HIGH);   //Turn left
    delay(700);
    
    digitalWrite(inputPin1, LOW);
    digitalWrite(inputPin2, LOW);
    digitalWrite(inputPin3, LOW);
    digitalWrite(inputPin4, LOW); //Stop turning
    
 }
}


else
 { 
    digitalWrite(inputPin1, LOW);
    digitalWrite(inputPin2, HIGH);
    digitalWrite(inputPin3, LOW);
    digitalWrite(inputPin4, HIGH);  //Move forward
    
   }
}
 
 int lookleft()
 {
  
  Servo1.write(180);
  delay(1000);
  
  
  // Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;

                                      
Servo1.write(90);
return distance;
 }

int lookright()
  {
   
  Servo1.write(0);
  delay(1000);
  
  
  // Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration2 = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration2*0.034/2;

return distance;

  }
    
   
   

  

Credits

yadukrishnan n

yadukrishnan n

1 project • 1 follower

Comments