Arduino Refresh Gets Faster Over Time?

I wrote a code to make it so when you press a button on an IR remote several times, it lights the correct LED. There are three options for this, so for example: in order to light the third led, you must press any button on the remote three times with one-second delay between every press maximum.

However, over time, that one-second delay gets faster, which is not intended. At first, it all works perfectly but then it starts checking so fast and always thinks it is only pressed once and only lights the LED number one.

Here is the code:

#include <IRremote.h>

int RECV_PIN = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;

int UP = 10;
int STOP = 11;
int DOWN = 12;
int Times[] = {0,0};

void setup() {
  pinMode(UP, OUTPUT);
  pinMode(STOP, OUTPUT);
  pinMode(DOWN, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode(&results)) {
    if (Times[0] < 3) {
      Times[0] = Times[0] + 1;
      Times[1] = millis();
    }
    irrecv.resume();
  }
  if (millis() - Times[1] > 1000 and Times[1] != 0) {
    if (Times[0] == 1) {
      digitalWrite(UP, HIGH);
      digitalWrite(STOP, LOW);
      digitalWrite(DOWN, LOW);
    }
    else if (Times[0] == 2) {
      digitalWrite(UP, LOW);
      digitalWrite(STOP, LOW);
      digitalWrite(DOWN, HIGH);
    }
    else if (Times[0] == 3) {
      digitalWrite(UP, LOW);
      digitalWrite(STOP, HIGH);
      digitalWrite(DOWN, LOW);
    }
    Times[0] = 0;
    Times[1] = 0;
  }
}

Usually, array are used to hold like kinds of data. Your Times array does NOT hold like kinds of data. It holds the number of times a button was pressed and the time that the button was last pressed.

Use two variables for two separate things.

If the button is pressed exactly 1000 milliseconds later than last time, the effect will be useless. Use >= to compare times, not >.

Your Serial.print() statements, and output, do not support your claims.

PaulS:
Your Serial.print() statements, and output, do not support your claims.

Can you clarify what you mean by this?

Also, I updated the code but the same issue still persists. The delay is removed after some time. Here it is:

#include <IRremote.h>

int RECV_PIN = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;

int UP = 10;
int STOP = 11;
int DOWN = 12;
int Times = 0;
int Last = 0;

void setup() {
  pinMode(UP, OUTPUT);
  pinMode(STOP, OUTPUT);
  pinMode(DOWN, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode(&results)) {
    if (Times < 3) {
      Times = Times + 1;
      Last = millis();
    }
    irrecv.resume();
  }
  if (millis() - Last >= 1000 and Last != 0) {
    if (Times == 1) {
      digitalWrite(UP, HIGH);
      digitalWrite(STOP, LOW);
      digitalWrite(DOWN, LOW);
    }
    else if (Times == 2) {
      digitalWrite(UP, LOW);
      digitalWrite(STOP, LOW);
      digitalWrite(DOWN, HIGH);
    }
    else if (Times == 3) {
      digitalWrite(UP, LOW);
      digitalWrite(STOP, HIGH);
      digitalWrite(DOWN, LOW);
    }
    Times = 0;
    Last = 0;
  }
}
int Times[] = {0,0};

Times is declared as an array of ints

     Times[1] = millis();

Here you are putting an unsigned long into the array

Problem ?

You just telling me "long" helped me fix it! I used "int" in the second version of the code and after it passed the maximum int could take, it started breaking.

Thanks for the help.

Can you clarify what you mean by this?

You don't HAVE any Serial.print() statements to help you learn what the program is doing. You are, therefore, debugging by guesswork, which is the hardest possible way to debug a program. Facts beat guesses EVERY time.

The proper type is not long. RTFM again.