//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 int loading = 0;
void tambahVariabel(){
counter += 1;
}
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
//setting pin interrup
pinMode(pin_trigger, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pin_trigger), tambahVariabel, LOW);
}
void loop()
{
if(loading < 20000)
{
for(int i = 0;i < 20000;i++)
{
loading += 1;
lcd.setCursor(0,1); //kolom, baris
lcd.print("Loading: ");
lcd.setCursor(10,1);
lcd.print(loading);
lcd.setCursor(0,2); //kolom, baris
lcd.print("Counter: ");
lcd.setCursor(10,2);
lcd.print(counter);
}
}
//program lain
}