Chandran NAyush SaranChandravaran KunjetiTarun HegdeSubham Mohapatra
Published © GPL3+

Home Safety Bot

A line follower bot which can detect gas leaks and high temperature in a typical household and raise an alarm.

EasyShowcase (no instructions)6 hours1,624
Home Safety Bot

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
Temperature Sensor
Temperature Sensor
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
IR receiver (generic)
×2
IR transmitter (generic)
×2
Breadboard (generic)
Breadboard (generic)
×1
9V battery (generic)
9V battery (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×10
Female/Female Jumper Wires
Female/Female Jumper Wires
×10

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
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

Code

Code implemented for the bot

Arduino
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
int sensorvalue2,sensorvalue1,tempsensor,gassensor;
#define rs A0
#define ls A1
#define temp A2
#define gas A3
#define sp 100
void setup()
{
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  Serial.begin(115200);
   pinMode(12,OUTPUT);
}
void loop()
{
  // this function will run the motors in both directions at a fixed speed
  // turn on motor A
  sensorvalue2 = analogRead(rs);
  sensorvalue1 = analogRead(ls);
  tempsensor=analogRead(temp);
  float c=((tempsensor/1024.0)*500);
  gassensor=analogRead(gas);
   if(sensorvalue2<100 && sensorvalue1<100) 
   {
     delay(30); 
  digitalWrite(in2, HIGH);
  digitalWrite(in1, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, sp);
  // turn on motor B
  digitalWrite(in4, HIGH);
  digitalWrite(in3, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, sp);
  
   }
   else if(sensorvalue2>100 && sensorvalue1 <100)
   {
    delay(30);
     digitalWrite(in2, HIGH);
  digitalWrite(in1, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, 0);
  // turn on motor B
  digitalWrite(in4, HIGH);
  digitalWrite(in3, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, sp);
  
   }
    else if(sensorvalue1>100 && sensorvalue2 <100)
   {
    delay(30);
     digitalWrite(in2, HIGH);
  digitalWrite(in1, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA,sp);
  // turn on motor B
  digitalWrite(in4, HIGH);
  digitalWrite(in3, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, 0);
 
   }
    else 
   {
    delay(30);
     digitalWrite(in2, HIGH);
  digitalWrite(in1, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, 0);
  // turn on motor B
  digitalWrite(in4, HIGH);
  digitalWrite(in3, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, 0); 
   }
   Serial.print("Temperature-");
   Serial.println(c);
   Serial.print("Gas sensor-");
   Serial.println(gassensor);
   if(c>=40)
   {
    tone(12,500,10);
    delay(100);
   }
   else if(c<40)
   {
    noTone(12);
   }
   if(gassensor>=250)
   {
    tone(12,500,10);
   }
   else if(gassensor<250)
   {
     noTone(12);
   }
   }

Credits

Chandran N

Chandran N

3 projects • 1 follower
I am a student at NITK Surathkal pursuing Mechanical Engineering.I am interested in Robotics,Arduino,IoT,Automobiles and Astronomy.
Ayush Saran

Ayush Saran

0 projects • 2 followers
Chandravaran Kunjeti

Chandravaran Kunjeti

0 projects • 0 followers
Tarun Hegde

Tarun Hegde

0 projects • 1 follower
Subham Mohapatra

Subham Mohapatra

1 project • 1 follower

Comments

Add projectSign up / Login