your fading code is blocking, so there is little point in trying to make the 1ms interval non blocking..
just make the full thing blocking
const unsigned long interval = 1; //amount of time the leds will stay up in millis
•••
// in loop, upon detection
for (int i = 0; i < 256; i++) {
analogWrite(LEDPIN, i);
delay(17);
}
delay(interval);
for (int i = 255; i >= 0; i--) {
analogWrite(LEDPIN, i);
delay(17);
}
if you want non blocking code, then use a state machine. Here is a small introduction to the topic: Yet another Finite State Machine introduction