//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
volatile unsigned long counter = 0;
byte pin_Trigger = 2;
unsigned long loading = 0;
void tambahVariabel(){
counter++;
}
void setup()
{
//setting pin interupt
pinMode(pin_Trigger, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pin_Trigger),tambahVariabel,LOW);
lcd.init();
// Print a message to the LCD.
lcd.backlight();
}
void loop()
{
if(loading<20000){
for(int i = 0; i < 20000; i++){
loading++;
lcd.setCursor(0,1);
lcd.print("Loading: ");
lcd.setCursor(10,1);
lcd.print(loading);
lcd.setCursor(0,2);
lcd.print("Counter: ");
lcd.setCursor(10,2);
lcd.print(counter);
}
}
}