gassensor

mail@pastecode.io avatar
unknown
plain_text
a year ago
390 B
1
Indexable
Never
int LED = 13;
int MQ2pin = A0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  float sensorValue;
  sensorValue = analogRead(MQ2pin);
  if(sensorValue >= 250)
  {
    digitalWrite(LED,HIGH);
    Serial.print(sensorValue);
    Serial.println("GAS DETECTED");
  }
  else
  {
    digitalWrite(LED,LOW);
    Serial.print(sensorValue);
  }
  delay(1000);
}