This is an old revision of the document!
— 1221B Denisa Florina Voicu
The scope of this project is to create a floor cleaning device that will make your cleaning days easier.This robot that resembles Roomba will have HC-SR04 ultrasonic distance sensors that will allow the robot to avoid obstacles so that it can move freely until the room is properly cleaned.It will also have an IR Module that will help it to avoid falling from stairs.
A robot that cleans your house's floor.The robot will have 3xHC-SR04 Ultrasonic Module on the sides and in the front that detect obstacles,also an IR Module to avoid falling down the stairs.The robot will be powered by a 7.4V Lithium-Ion Battery.Because the battery is too powerful we will use a voltage regulator to convert it to 5V.We switch the button to ON and the vacuum will start working after we cut the connection from the internal battery and power it from our power supply.For the motor driver, we connect the two enable pins to 5V and also the driver voltage pin to 5V because we are using 5V motors.
List of components:
Electric scheme:
I used Arduino IDE to write and upload the code.
Defining the pins:
const int trigPin1 = 3; const int echoPin1 = 5; const int trigPin2 = 6; const int echoPin2 = 9; const int trigPin3 = 10; const int echoPin3 = 16; int irpin =2;
Defining the variables:
long duration1; long duration2; long duration3; int distanceleft; int distancefront; int distanceright; int a=0;
This section is used to move forward and backward:
if(s==HIGH) { digitalWrite(4, LOW); digitalWrite(7, HIGH); digitalWrite(8, LOW); digitalWrite(14, HIGH); delay(1000); a=1; }
If it detects the abscence of the floor the robot will not move forward and it will turn around :
if ((a==0)&&(s==LOW)&&(distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (a==0)&&(s==LOW)&&(distanceleft > 15 && distancefront > 15 && distanceright > 15))
This section is used to move right:
digitalWrite(4, LOW); digitalWrite(7, HIGH); digitalWrite(8, LOW); digitalWrite(14, HIGH); delay(1000); a=1;
if ((a==1) &&(s==LOW) ||(s==LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s== LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s==LOW) && (distanceleft <= 15 && distancefront > 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15)) { digitalWrite(4, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(14, HIGH); delay(100); a=0; }
This section is used to move left:
if ((s==LOW)&&(distanceleft > 15 && distancefront <= 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront > 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront <= 15 && distanceright > 15) ) { digitalWrite(4, LOW); digitalWrite(7, HIGH); digitalWrite(8, HIGH); digitalWrite(14, LOW); }