Newb needs help with interrupts

Hi,

This is only my third sketch. Before this I only flashed leds and controlled a fan based on temp.

What I am doing is flashing a light three times and then leaving it on for a while then flashing it again. That is the easy part.

It should only be on when it receives a signal on the Xbee. I have that part figured out. What I am having trouble with is inserting an interrupt to shut the light off if I stop receiving signal from my xbee.

Should I be looking at something other than interrupts? Timers maybe?

I won't bore you with my failed interrupt attempts. This is my code before I try to add an interrupt. I Have to wait till it goes through the loop before it will stop. That is fine for flashing but not for longer delays at the end.

If someone could edit it for me that would be great. I am also open to any suggestions or opportunities learn.

Thanks for looking.

// spanker light control
// r1 = relay 1
// xbee pin 20 is connected to pin 7

int xbee = 7;  // pin 7 input from xbee pin 20
int r1 = 2;    // pin 2 output to relay 1 on shield
int val = 0;   // variable to store the read value

void setup(){

pinMode (xbee, INPUT);   // declare xbee as input
pinMode (r1, OUTPUT);   // declare r1 as output
}

void loop(){
  
val = digitalRead(xbee); //read input pin

if (val == HIGH) {
digitalWrite(r1, HIGH);    // turn light on
delay (500); // wait .5 seconds
digitalWrite(r1, LOW);    // turn light off
delay (500); // wait .5 seconds
digitalWrite(r1, HIGH);    // turn light on
delay (500); // wait .5 seconds
digitalWrite(r1, LOW);    // turn light off
delay (500); // wait .5 seconds
digitalWrite(r1, HIGH);    // turn light on
delay (90000); // wait 90 seconds
}
else {
digitalWrite (r1, LOW);
}
}

My project. We have two fin spanking machines at work. I need to turn a light on when either of them are powered up. I Have the Xbee hardware side working. I would just like for it to flash a few time when it comes on and then again every few minutes.

Wall wort - a sweet liquid drained from mash and fermented to make beer and whiskey tossed on the wall for added flavor. There Is a hint of gypsum, paper, and old paint in your fine whiskey. :D

Blink without delay. Learn it. Apply it. Your troubles will disappear like a fine whiskey.

Interrupts. Stay away as long as possible. Only apply as a last resort. Your troubles will stay away like a wall wort whiskey.

As Coding Badly says, an interrupt is not needed.

An interrupt is something that occurs (not generally something that you make occur) that needs immediate attention.

In your code, a simple restructure, using millis() and a state machine, is all that is needed.