Arduino code:
/*
code started
gsm lpg leakage project
#defibe sensor = 2;
code created by technical ideas yt
https://youtube.com/c/TechnicalidEas07
*/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
int state = 0;
const int pin = 2;
void setup()
{
lcd.init();
lcd.init();
lcd.backlight();
lcd.begin(16,2);
lcd.setCursor(0, 0);
lcd.print("Hey");
lcd.setCursor(0, 1);
lcd.print("Innovative Army");
delay(3000);
lcd.clear();
Serial.begin(9600);
}
void loop()
{
if (digitalRead(pin) == HIGH && state == 0) {
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
//Replace XXXXXXXXXX to 10 digit mobile number
Serial.print("AT+CMGS=\"+91XXXXXXXXXX\"\r");
delay(1000);
//The text of the message to be sent.
Serial.print("Gas leakage detected");
lcd.setCursor(0, 0);
lcd.print(" Gas Leakage");
lcd.setCursor(0, 1);
lcd.print(" Detected ");
delay(3000);
lcd.clear();
delay(1000);
Serial.write(0x1A);
delay(1000);
state = 1;
}
if (digitalRead(pin) == LOW && state == 1) {
state = 0;
}
}
1 Comments
very easy
ReplyDelete