Receiving RF for status and on demand actions

I'm writing a garage door opener and status monitor. The opener is uses relays to open and close a circuit on the remote. I also have a 315 mhz receiver accepting the status of the door, but this runs in the same loop as the open and close request, so every time I open or close the door, it first checks the status. What I really want to do is check the status every 20 seconds or so, and open the garage on demand (a get request to the webserver).

I posted the code at github (the status check really is just a serial output of the distance of the garage door, but in theory alternative methods could be used).

I'm a c# developer by trade, and only do arduino programming for fun, so I'm definitely no expert.

Thanks for any advice in advance,
Drew

You would be best served by creating a function that would be for checking the door status. Then, use the "blink with out delay" example to check status of the door at your interval that you choose.

Something similar to the small part of code below:

unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   
  
  // some function to check door status
  
  }

THANK YOU! That was exactly what I needed to get me moving in the right direction. By the way, if anyone is interested, I posted the code on github: Arduino-GarageDoorOpener/GarageDoorOpener.ino at master · dhysong/Arduino-GarageDoorOpener · GitHub