timing for sleep

I am running a code and after nothing has happened for so long the display shut off to conserve power (maybe the arduino sleep too but another topic). The time I am trying to get is to at least 10 minutes and preferably 15. I cant use the delay i am used to because I have to "watch" the buttons instead of stopping the code for x seconds.

Right now the main code is checking for button pushes. A simple version is:

void loop(){
Check Left Button;
// do this
Check Right Button;
// do this
}
and change to something like:

void loop(){
if timer<999,9999{
Check Left Button;
// do this
timer=0;
Check Right Button;
// do this
else{
Sleep;
timer=0;
}
}

I tried the second example and it slowed it down setting the timer threshold up to 9,999. After that nothing. I think it has to do with me storing timer as an integer, but am new and not sure. Is there a better way, do I need use something besides an integer?

do I need use something besides an integer

An "unsigned long" integer?

On the Arduino, an "int" is good for the range -32 768...+32 767, and "unsigned int" is 0...65 535, but an "unsigned long" is 0...232-1 (0...4 294 967 295)

Also note that there is a big difference between

timer = 0;

and

timer == 0;

The first sets the value of timer to 0. The second compares the value of timer to 0, and returns true or false. The return value is discarded. The value in timer is not changed.

good catch paul. It was late. In my original code it is a "=" instead o "==". updated my code to show.

The unsigned long int is what I was needing. That explains why I could slow it down up to 9,999 but after that nothing.