Toll-Free Customer Support 24/7

GAS ARDUINO CODE

/*
 * Project name:
     GAS sensor  
 * Copyright
     (c) Researchdesignlab.com
 * Description:
    
 * Test configuration:
     MCU:             ATMEGA328
     Dev.Board:       Arduino uno
     Oscillator:      16 MHz
     Software:        Arduino

*/



#include <LiquidCrystal.h>  // initialize the library with the numbers of the                                   

LiquidCrystal lcd(6, 7, 2, 3, 4, 5);            
   
/*
 * LCD RS pin to digital pin 6
 * LCD Enable pin to digital pin 7
 * LCD D4 pin to digital pin 2
 * LCD D5 pin to digital pin 3
 * LCD D6 pin to digital pin 4
 * LCD D7 pin to digital pin 5
 * LCD R/W pin to ground  */

const int gasPin = 12; 
int gasState = 0;

void setup() 
{  
  pinMode(gasPin, INPUT);            // initialize the GAS sensor pin as an input:  
  
  lcd.begin(16, 2);                  // set up the LCD's number of columns and rows: 
 
}

void loop() 
{
 gasState = digitalRead(gasPin);
// if it is, the GAS sensor is HIGH:  

 if(gasState == LOW)
 { 
   lcd.setCursor(0,1);   
   lcd.print("gas detected");        // Print a message to the LCD.
 
 }
 
else
{
  lcd.setCursor(0,1);
  lcd.print("no gas detected");

}
}

Back to top