if (time passed and nothing received)

I'm working on a project that involves receiving signals from another Arduino via the Nrf24l01 chips and the RF24 library. I am writing a code to deal with the event in which nothing was received. I am looking for a line of code I could use sort of like:

if(3000ms has passed and nothing received) {
Serial.print("Nothing received"); //possibly execute a "backup" function here
}

Hopefully someone understands where I'm coming from. Any more questions don't hesitate to ask. Thanks!

Every time you receive a message, set a variable named lastTimeAMessageWasReceived to millis().

Then you can check if millis - lastTimeAMessageWasReceived is greater than a certain value.

I wrote a code snippet about this in another Thread in the last few days but I can't remember which one. Google might find it for you. It was similar to @Arrch's advice.

...R

I have this so far:

  if(curMillis - receivedMillis >= timeoutMillis){
    currentScene = newScene;
    newScene = currentScene + increment; //set up increment for next loop
    receivedMillis = curMillis;
    delay(waitTime); 
  }

and I am receiving numbers from other arduinos and have newScene as a global variable set by default to 0 and the currentScene just holds the current received number. For number 1, when its supposed to be received but forces a timeout I get a timeout for scene 0 and scene 1. I tried putting an extension on the if():

if(curMillis - receivedMillis >= timeoutMillis && newScene != 0)

but that seemed to stop any advancement of the code because there is nothing to update the newScene variable.

Dan,

Think about maintaing a state number in your code that you use to maintain the last station you visited. It can be something like this:

if (received RadioIDof (Station + 1))
then 
  {
    Station = Station + 1;
    Play(Station);
  }
else 
{
  (keep looking for RadioIDof (Station + 1)
}

DanBrookwell:
I have this so far:

  if(curMillis - receivedMillis >= timeoutMillis){

currentScene = newScene;
    newScene = currentScene + increment; //set up increment for next loop
    receivedMillis = curMillis;
    delay(waitTime);
  }

You seem to have figured out how to use millis() so why bother with delay()?

...R