mq2

parent 767469d7
int gas =A2;
int value = 0;
void setup() {
pinMode(gas,INPUT);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
value = analogRead(gas);
Serial.println(value);
delay(100);
if(value> 220){ //cahnge with your val
digitalWrite(13,HIGH);
Serial.print("LPG gas was detected");Serial.println(value);
delay(10);
}
else{
digitalWrite(13,LOW);
delay(10);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment