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 90 minutes. (We use the same ascent rate and the last 5 flights show us moving past this mark with a margin or error of 3 minutes, which is acceptable for what we are doing) 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 = 15601000UL; // 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