0% found this document useful (0 votes)
7 views1 page

Lpgdetector Code

The document contains an Arduino sketch that reads data from a gas sensor and activates a buzzer and LED indicators based on the sensor readings. If the gas level exceeds a threshold, it sends an SMS alert to a specified phone number. The code includes setup and loop functions to handle sensor input and output control for a relay and visual indicators.

Uploaded by

Rashidul Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Lpgdetector Code

The document contains an Arduino sketch that reads data from a gas sensor and activates a buzzer and LED indicators based on the sensor readings. If the gas level exceeds a threshold, it sends an SMS alert to a specified phone number. The code includes setup and loop functions to handle sensor input and output control for a relay and visual indicators.

Uploaded by

Rashidul Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<SoftwareSerial.

h>
SoftwareSerial mySerial(2,3);
int sensor=A0;
int buzzer=13;
int green=12;
int red=11;
int relay=10;
int data;
void setup()
{
pinMode(sensor,INPUT);
pinMode(buzzer,OUTPUT);
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);
pinMode(relay,OUTPUT);
[Link](9600);
[Link](9600);
delay(100);
}
void loop()
{
data=0;
data=analogRead(sensor);
[Link](data);
if(data>450)
{
SendMessage();
digitalWrite(buzzer,HIGH);
digitalWrite(red,HIGH);
digitalWrite(green,LOW);
digitalWrite(relay,LOW);
}
else
{
digitalWrite(buzzer,LOW);
digitalWrite(green,HIGH);
digitalWrite(red,LOW);
digitalWrite(relay,HIGH);
}
}
void SendMessage()
{
[Link]("AT+CMGF=1");
delay(1000);
[Link]("AT+CMGS=\"+8801302482643\"\r");
delay(1000);
[Link]("Ecess Gas Detected.");
delay(100);
[Link]((char)26);
delay(1000);
}

You might also like