Timed Backlight

...what I want it to do...

Maybe try pseudo-code.

First a couple of notes:

It makes more sense to me to use "offTime" as the variable name to indicate when the LED will be turned off.

Then, instead of doing a subraction, just compare present time with offTime. The logic seems more obvious to me. (Also: see the footnote.)

Anyhow, here's how the logic lays itself out for me:

loop:

  IF button_is_pressed THEN
      offTime = presentTime + onDuration;
  END IF
  
  IF (presentTime < offTime) THEN
      Turn_on_the_LED
  ELSE
      Turn_off_the_LED
  END IF

For the real code, "presentTime" is just millis(), right? I mean you can use a separate variable, but it's not really necessary.

Regards,

Dave

Footnote: If you subtract unsigned long ints, the result is an unsigned long int. Can't be less than zero.