Wednesday, 21 December 2016

2.2 Software Programming


2.2      Software programming

The software that we used to create this source code is Arduino Software


#include <Wire.h> // Provide within Arduino IDE
#include <LiquidCrystal_I2C.h> //LCD-I2C library

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  //LCD Port configuration
const int sensorPin= 0;

const int ledPin= 13;
const int ledPin2= 12;
int gas_level;

void setup() 
{
Serial.begin(9600);  // Serial baud rate configuration
lcd.begin(16,2);   //Intialization LCD
Serial.begin(115200); //sets the baud rate for data transfer in bits/second
pinMode(sensorPin, INPUT);//the gas sensor will be an input to the arduino
pinMode(ledPin, OUTPUT);//the LED serves an output in the circuit
pinMode(ledPin2, OUTPUT);//the LED serves an output in the circuit
lcd.begin(16, 2);
lcd.print("    LPG  GAS    ");
lcd.setCursor(0,1);
lcd.print("    DETECTOR    ");
delay(2000);
}



void loop()
{
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, LOW);
lcd.clear();
lcd.print("     GAS     ");
lcd.setCursor(0, 1);
lcd.print("   DETECTED  ");
delay(400);
digitalWrite(ledPin, LOW);
delay(500);
   

}
else{

digitalWrite(ledPin2, HIGH);
lcd.clear();
lcd.print("     NO GAS    ");
lcd.setCursor(0,1);
lcd.print("    DETECTED    ");
delay(1000);

}
}