#include <LiquidCrystal_I2C.h>

int btnRE = 0;
int redLed = 9;
int blueLed = 8;
int buzzer = 10;
int i = 0;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);
  pinMode(redLed,OUTPUT);
  pinMode(blueLed,OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(2, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(2),buttonPressed, LOW);

  lcd.clear();
  lcd.backlight();
  lcd.init();
  lcd.begin(16,2);
}

void loop() {
    btnRE = digitalRead(2);
    digitalWrite(blueLed, HIGH);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(i);
    i++;
    for(int j=0; j <100; j++){
      lcd.setCursor(0,1);
      lcd.print(j);
      delay(500);
    }
    if(i==100){
      i=0;
      lcd.clear();
      lcd.setCursor(0,0);
    }
   
 
delay(200);
}

//This is simple method which changes states  of leds. It is made so user can see what is happening when interrupt routine is used
void buttonPressed()
{
    digitalWrite(10, LOW);
    for(int k = 0; k<100; k++)
{
  digitalWrite(10, HIGH);
  delay(500);
  digitalWrite(10, LOW);
  delay(100);
}
    digitalWrite(8,LOW);
    digitalWrite(9,HIGH);
    delay(100000);
    digitalWrite(9,LOW);
    delay(100000);
    digitalWrite(9,HIGH);
    delay(100000);
    digitalWrite(9,LOW);
    delay(100000);
    digitalWrite(9,HIGH);
    delay(100000);
    digitalWrite(9,LOW);
    delay(100000);
    digitalWrite(8,HIGH);  
  delay(2000);
}