John Baptist Rodrigues
Published

Roombot: Room Cleaning Robot

Roombot is a room cleaning robot that moves around the room avoiding obstacles, picking up dust and wiping the floor.

IntermediateWork in progress21,964
Roombot: Room Cleaning Robot

Things used in this project

Story

Read more

Custom parts and enclosures

CAD Assembly

Schematics

Circuit Diagram

Code

obstacle avoiding

C/C++
const int trigPin = 11;
const int echoPin = 10;
const int in1 = 9;
const int in2 = 8;
const int in3 = 4;
const int in4 = 3;


void setup() 
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode (in1, OUTPUT);
  pinMode (in2, OUTPUT);
  pinMode (in3, OUTPUT);
  pinMode (in4, OUTPUT);
}
long duration, distance;

void loop()
{     
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);  
  duration = pulseIn(echoPin, HIGH);
  distance = duration/58.2;
  if(distance<15)
    {
      digitalWrite(in1, LOW); 
      digitalWrite(in2, HIGH); 
      digitalWrite(in3, HIGH); 
      digitalWrite(in4, LOW);
    }
  else
    {
      digitalWrite(in1, HIGH); 
      digitalWrite(in2, LOW); 
      digitalWrite(in3, HIGH); 
      digitalWrite(in4, LOW);
    }  
  delay(50);
}

Credits

John Baptist Rodrigues

John Baptist Rodrigues

1 project • 18 followers
I am John Rodrigues,Mechanical Design Engineer by profession| blogger and writer at designwithjohn.com

Comments