Run code for X duration, pause and repeat function

I am trying to modify a code for my use. I want to do a simple led blink for a duration of 10000 and pause for 10000 and repeat the loop. The code was modify from running a motor toggle between on and off, not sure how to make it work for the led blinking. Please help.

int led = 2; //define which pin to use
boolean Status = false; //motor off
long onDuration = 10000; //how many ms to stay on
long offDuration = 10000; //how many ms to stay off
unsigned long NextToggle = millis()+offDuration; //next time we do anything is in x ms from power on

void setup()
{

pinMode(led,OUTPUT); //set up led pin

} //end setup


void loop()
{
if (millis() > millis() + offDuration) //check to see if current time exceeds the timestamp we set.
{//time has elapsed
ledToggle(); 
}
else
{ //time hasn't elapsed
//don't care, don't do anything
} //end if
//*************here is where all the other code you could want would go

//*************this gets looped regardless of whether we are waiting or not!
} //end loop

void ledToggle(){
ledStatus = !ledStatus; //toggle if was on/off
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);  
if (ledStatus=true)//blink is turned on
{
NextToggle = millis() + onDuration;
}
else
{ //blink is turned off
NextToggle = millis() + offDuration;
} //end if
}//end

Your description is not clear. Do you want it ON for 10 seconds, then OFF for 10 seconds, or BLINKING for 10 seconds, then OFF for 10 seconds?

I want to blink for 10sec and pause for 10sec. Thanks

shadowless:
I want to blink for 10sec and pause for 10sec. Thanks

so for your first step, you need to replace this line:

    //don't care, don't do anything

with something like:

     if (ledStatus == true)
     {
          digitalWrite(Led, ON);
          delay(500);
          digitalWrite(Led, OFF);
          delay(500);
     }

You are confusing me more .

shadowless:
You are confusing me more .

Then I will stop. I am not confusing you more. You need to understand your code.

A present for you

byte state = 0;
unsigned long stateStartTime;
unsigned long statePeriod = 10000;
unsigned long blinkStartTime;
unsigned long blinkPeriod = 200;
unsigned long currentTime;
const byte ledPin = 13;

void setup()
{
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  stateStartTime = millis();
}

void loop()
{
  switch (state)
  {
    case 0:  //wait with LED off
      currentTime = millis();
      if (currentTime - stateStartTime >= statePeriod)
      {
        stateStartTime = currentTime;
        blinkStartTime = stateStartTime;
        state = 1;
      }
      break;

    case 1:  //flash LED
      currentTime = millis();
      if (currentTime - stateStartTime >= statePeriod)
      {
        stateStartTime = currentTime;
        state = 0;
      }

      if (currentTime - blinkStartTime >= blinkPeriod)
      {
        digitalWrite(ledPin, !digitalRead(ledPin));
        blinkStartTime = currentTime;
      }
      break;
  }
}

Have a look at the demo Several Things at a Time. It illustrates the use of millis() for timing and flashes 3 leds.

...R

Thanks for the present and the link. Really helpful.

As a thank you for the present can I ask that you post the code back here with comments added explaining how it works or your best guess ? There are a number of useful and important techniques used in the program which will come in useful in later, more complicated programs so it is a good idea to understand how/why it works so that you can apply the ideas in later projects.

Some questions for you to ponder :

Why is state declared as a byte and not an int ?
Why are the timing variables declared as unsigned long ?
Why is the ledPin variable declared as const byte ?
Why is subtraction used when comparing times rather than adding the period to the current time ?
How is the LED turned on and off with no variable to hold its current state ?

Really want to learn more about this, are there any good internet sites that you can recommend?

shadowless:
Really want to learn more about this, are there any good internet sites that you can recommend?

Sure. Here.