#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
int buzzer = 8;

void setup()
{
  lcd.begin(16, 2);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(8,OUTPUT);
}

void loop() {

  int gas_data;
  gas_data = analogRead(A0);
  lcd.setCursor(0,0);
  lcd.print("Gas   :");
  lcd.setCursor(0,1);
  lcd.print("Status:");
  lcd.setCursor(7,0);
  lcd.print(gas_data);

  if(gas_data > 900){
    digitalWrite(9,HIGH);
    tone(buzzer,2000,500);
    delay(100);
    digitalWrite(9, LOW);
    lcd.setCursor(7,1);
    lcd.print("BAHAYA");

  }else if(gas_data > 500){
    digitalWrite(10,HIGH);
    tone(buzzer,1500,500);
    delay(100);
    digitalWrite(10, LOW);
    noTone(buzzer);
    lcd.setCursor(7,1);
    lcd.print("HATI HATI");

  }else {
    digitalWrite(11,HIGH);
    delay(100);
    lcd.setCursor(7,1);
    lcd.print("AMAN");
  }
  delay(100);
  lcd.clear();
}