Accident Coding
Accident Coding
Accident Coding
h>
LiquidCrystal lcd(8,9,4,5,6,7);
#include <SoftwareSerial.h>
SoftwareSerial ESP11 = SoftwareSerial(2,3); // RX, TX
int gas=A0;
int sounds=A1;
int irs=A2;
int ir=0;
int sound=0;
float tp=0;
float mv=0;
int cel=0;
int gs=0;
int h=0;
void setup() {
lcd.begin(16,2);
Serial.begin(115200);
ESP11.begin(115200);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
pinMode(11,OUTPUT);
digitalWrite(11,LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Loading!....");
sendData("AT+CWMODE=3\r\n",2000,DEBUG); // configure as access point and Client
lcd.setCursor(0,1);
lcd.print(" 20% ");
sendData("AT+RST\r\n",2000,DEBUG); // reset module
lcd.setCursor(0,1);
lcd.print(" 40% ");
lcd.setCursor(0,1);
lcd.print(" 90% ");
sent();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SM: I:");
lcd.setCursor(0,1);
lcd.print("SD: ");
void loop() {
gaslvl();
sound=analogRead(sounds);
if(sound>999)
sound=999;
lcd.setCursor(3,1);
lcd.print(" ");
lcd.setCursor(3,1);
lcd.print(sound);
if(sound>600)
{
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("High Sound");
lcd.setCursor(0,1);
lcd.print("Detected");
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(4000);
digitalWrite(11,LOW);
sent();
}
if(digitalRead(irs))
{
ir=1;
lcd.setCursor(11,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print("HG");
}
else
{
ir=0;
lcd.setCursor(11,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print("LW");
}
sent();
}
void gaslvl()
{
gs=analogRead(gas);
gs/=10;
if(gs>100)
gs=100;
lcd.setCursor(3,0);
lcd.print(" ");
lcd.setCursor(3,0);
lcd.print(gs);
if(gas>60)
{
lcd.setCursor(0,0);
lcd.print("High Smoke");
lcd.setCursor(0,1);
lcd.print("Detected");
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(4000);
digitalWrite(11,LOW);
sent();
}
}
}
}
}
if(debug)
{
}
return response;
}
void sent()
{
getStr+=gs;
getStr+="&sound=";
getStr+=sound;
getStr+="&ir=";
getStr+=ir;
sendData(cmd + "\r\n",1000,DEBUG);
sendData(getStr,1000,DEBUG);//200
String closeCommand = "AT+CIPCLOSE";