How to use gas sensor with arduino


Materials:-

  • Arduino uno
  • Gas sensor
  • LED
  • jumper wires
Connnections:-

        Gas sensor  VCC = Arduino 5V
        Gas sensor GND =Arduino GND
        Gas sensor    VO =Arduino Analog pin 3
        LED ( + )   = Arduino Digital pin 13
        LED ( - )    =Arduino GND

Code:-

//https://mrarduinoprojects.blogspot.com
int Led = 13;
int smoke = A3;
int sensorThres = 500;

void setup() {
  pinMode(Led, OUTPUT);
  pinMode(smoke, INPUT);
  Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smoke);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  if (analogSensor > sensorThres)
  {
    digitalWrite(Led, HIGH);
  }
  else
  {
    digitalWrite(Led, LOW);

  }
  delay(100);
}