#include <LiquidCrystal_I2C.h>
/* Display */
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int buttonPin = 2;
const int potPin = A0;
int gasValue = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup() {
lcd.begin(16, 2);
pinMode(buttonPin, INPUT);
lcd.setCursor(5, 0);
lcd.print("SENSOR");
lcd.setCursor(1, 1);
lcd.print("PENDETEKSI GAS");
delay(1000);
}
void loop() {
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH && lastButtonState == LOW){
int potValue = map(potValue, 0, 1023, 0, 100);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BESAR GAS : ");
lcd.print(gasValue);
delay(500);
}
lastButtonState = buttonState;
}