Cant lcd.clear when lcd on countdown

Hello
I Wanted to make a Arduino countdown using LCD and IR receiver, 1 minute countdown begins when i press 1 on IR Remote, and if i want the countdown to stop I made a External interrupt with a button to make LCD clear when pressed, but LCD wont be cleared when i press button but LCD clear happens when countdown ends, can someone help me with this.
Thankyou in Advance :slight_smile:

//The code


#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <IRremote.h>
volatile bool clsRequested = false;
int receiver_pin = 9;
float i;

int button = 2;
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x20, 16, 2);
IRrecv receiver(receiver_pin);
decode_results output;

#define code1  41565
#define clear0 39015 // to clear lcd
#define codeok 14535
unsigned int value;
void setup()
{
  // initialize the LCD
  lcd.begin();
  Serial.begin(9600);
  receiver.enableIRIn();
  lcd.print("Hello");  
  pinMode(2, INPUT_PULLUP);
  attachInterrupt (digitalPinToInterrupt (button), lcdclear, FALLING);
}

void loop()
{
  if (clsRequested == true)
  {
    lcd.clear();
    clsRequested = false;
  }

  if (receiver.decode(&output)) {
    value = output.value;
    switch (value) {
      case clear0:// clear lcd
        lcd.clear();
        break;
      case code1:// prints 1 minute
        lcd.clear();
        oneminute();
        break;
    }
    Serial.println(value);
    receiver.resume();
  }
}
int oneminute() { //1 minute function
  for (i = 0.60; i > 0.00; i -= 0.01) { //reduces 0.01 from 0.60
    lcd.setCursor(0, 0);
    lcd.print(i);
    i -= 0.01;
    delay(1000);


  }
}
void lcdclear() {
  clsRequested = true;
}

This looks suspiciously like the query in your other topic Lcd.clear using External Interrupt where it was pointed out that you don't need an ISR to do what you want

I am closing this topic. Please continue in your other topic