#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); //I2C (address,column,row)
int Time = 0;
int ADC_v=0;
int Range=200;
int AnalogPin =A0;
int DT=0;
const int ISR_pin = 2;
int Result=0;
int x=0;
void setup() {
Serial.begin(115200);
pinMode(ISR_pin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ISR_pin), countdown, LOW);
//attachInterrupt(2, countdown, FALLING);
lcd.begin(20,4); //number of column,row
lcd.backlight();
lcd.setCursor(0,0); // set column = 0 ,row = 0
lcd.print("Welcome"); // LCD print
lcd.setCursor(0, 2); // set column = 0 ,row = 1
lcd.print("Timer Countdown"); //LCD print
delay(1000);
lcd.clear();
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
ADC_v=analogRead(AnalogPin);
Time= ((float)ADC_v/1023)*Range;
lcd.setCursor(0,0); // set column = 0 ,row = 0
lcd.print("ADC="); // LCD print
lcd.setCursor(5,0); // set column = 0 ,row = 0
lcd.print(Time); // LCD print
delay(100);
lcd.clear();
DT=Time;
}
void countdown(){
lcd.clear();
lcd.setCursor(0,0); // set column = 0 ,row = 0
lcd.print("Push Button"); // LCD print
delay(1000);
lcd.clear();
}