Pause Countdown with I2C

Hi!

I'm trying to use I2C to have an LCD + Keypad stop a countdown clock. I have it so when the correct code is entered, the clock should stop where it is and change color, but for some reason it isn't working. (I did get it working once, but it stopped about 5 minutes after code was entered).

The "Master" code is set to change x to 1 when the correct code is entered.

Here is the receiver code on the countdown:

#include "Lixie.h" // Include Lixie Library
#include <Wire.h>

#define DATA_PIN   1
#define NUM_LIXIES 2
Lixie lix(DATA_PIN, NUM_LIXIES);

uint32_t count = 60;

int x = 0;

double counter = 60000;
int minute = 1;

const byte lockPin = A0;

void setup() {

  lix.begin(); // Initialize LEDs
  lix.color(255, 99, 71); //green
  lix.max_power(5, 450); // Set software power limit
  pinMode(lockPin, OUTPUT);
  digitalWrite(lockPin, LOW);

  
  Wire.begin(9);
  Wire.onReceive(receiveEvent);
}




void receiveEvent(int bytes) {
  x = Wire.read();

}

void loop() {
  lix.write(count); // Display count


  

  if (x == 1)
  {
    //system("pause");
    lix.color(0, 0, 255); //blue
    cli();
    while ( true );
  }

  


  if (count > 0 && x == 0  )
  {
    count--;
  }




  if (count == 1 && minute == 1)
  {
    minute = 0;
    count = 60;
    counter = 1000;
    lix.color(255, 0, 0); //red
  }



  // SOLVED?
  if (count == 0)
  {
    digitalWrite(lockPin, HIGH);
  }

  delay(counter);
}

I'd really appreciate it if anyone can tell me what I'm doing wrong, thanks!

You realise that when x == 1 your machine shuts down? For good. No wakeup. Nothing but a hardware reset will get it going again.

I had it at x != 1 and it still did the same thing.

And I want the timer to be stopped until I reset it anyway.

What I'm suggesting is that you disable global interrupts and then enter an endless loop. Nothing will break that.