Help needed with timer code

I am an astronomy professor at UVU. We are trying to launch a high altitude balloon soon with a pre-dawn launch. FAA rules require a beacon up to at least 60,000 ft. We would like to have the LED turn itself off, due to some other experiments on board, after 15 minutes. I am afraid I don't have the C+ skills to draw up this draft, and was hoping someone could help me insert this "if" function in the Millis() code and then create a Boolean false to end the blinking LED after the time runs out. Is there anyone that might be able to help with this? Here is code of the blinking LED.

// These variables store the flash pattern // and the current state of the LED

int ledPin = 13; // the number of the LED pin int ledState = LOW; // ledState used to set the LED unsigned long previousMillis = 0; // will store last time LED was updated long OnTime = 250; // milliseconds of on-time long OffTime = 750; // milliseconds of off-time

void setup() { // set the digital pin as output: pinMode(ledPin, OUTPUT); }

void loop() { // check to see if it's time to change the state of the LED unsigned long currentMillis = millis();

if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime)) { ledState = LOW; // Turn it off previousMillis = currentMillis; // Remember the time digitalWrite(ledPin, ledState); // Update the actual LED } else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime)) { ledState = HIGH; // turn it on previousMillis = currentMillis; // Remember the time digitalWrite(ledPin, ledState); // Update the actual LED } }

I think I want to insert an "if"function something like this, but I don't know how or where to put it. This was given to me by LarryD on another part of the forum, but I have tried and am not able to do much with it:

my15MinuteMillis = 15*60*1000UL; // my15MinuteMillis must be "unsigned long" Use this variable in a "if" function, when the time has expired, make a Boolean false which then prevents the led from toggling. Thanks ahead of time for your assistance Kent

Isn’t it just a case of this?

int ledPin =  13;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
long OnTime = 250;           // milliseconds of on-time
long OffTime = 750;          // milliseconds of off-time
unsigned long my15MinuteMillis = 15*60*1000UL; 

void setup() 
{
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      
}

void loop()
{
  // check to see if it's time to change the state of the LED
  unsigned long currentMillis = millis();
 
  if( currentMillis < my15MinuteMillis )
  {
    if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
      ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);     // Update the actual LED
    }
  }
}

FAA rules require a beacon up to at least 60,000 ft. We would like to have the LED turn itself off, due to some other experiments on board, after 15 minutes.

Are you really going to climb 60,000 feet in 15 minutes? Turning the beacon off when you get to the appropriate altitude would be better than guessing how long the beacon should be on.

Tammy and Paul, thank you very much for your responses. Tammy, the sketch works great, but doesn't turn the LCD off after designated time. The light stops blinking, but remains on. Any thoughts how to stop it all together?

Paul, you are right. We shouldn't guess. I was too lazy earlier to look at our previous data and threw out 15 min, understanding we would change that. Our last 5 flight data logs show us moving past 60,000 within 90 min.

Thanks again for the help on this. Any ideas Tammy on how to write the sketch to include a shut off of the LED?

Hi Paul, I should also add that we try to use the same ascent rate on all our flights and the margin or error for hitting the 60,000 ft mark has been within 3 minutes, which is acceptable for what we are trying to do. Winds aloft influences the rate a bit. Thanks again for your thoughts. Any ideas on how to write the sketch so it will shut off the light?

int ledPin =  13;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
long OnTime = 250;           // milliseconds of on-time
long OffTime = 750;          // milliseconds of off-time
unsigned long my15MinuteMillis = 15*60*1000UL; 

void setup() 
{
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      
}

void loop()
{
  // check to see if it's time to change the state of the LED
  unsigned long currentMillis = millis();
 
  if( currentMillis < my15MinuteMillis )
  {
    if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
      ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);     // Update the actual LED
    }
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
}
unsigned long my15MinuteMillis = 15*60*1000UL;

I really don't like this name. If the time needs to change, renaming the variable should not be necessary.

Not keen on the name either, it was just what was presented in the first post.

Personally I'm not overly keen on the reliance of the balloon travelling 60,000 feet in 15 minutes either.

Also seems overkill to have a micro controller flashing an LED.

Tammy, this worked great. Thank you. The name was created by another forum member who was trying to help. Your's and Paul's point is well taken. I have since changed the name to "mytimerMillis"

Tammy, we are using the micro controller to kill the LED since we will be taking video and stills of near space up to 120,000. We need to reduce the ambient light as much as possible.

Thank you both again.