Hopefully a simple question.
I'm wondering how you do a "delay" without delaying the whole project.
Example:
if (RelayTrigger == HIGH) {
digitalWrite(LED, HIGH);
delay(15000);
digitalWrite(LED, LOW);
etc...........
How can I tell something like an LED or Motor, or Solenoid or any Output for that matter to be active for a certain amount of time without putting in the delay?
Because if that delay is in there, it won't get to the rest of the programming until that delay has been executed.
Is it something that I define in the setup for a pin?
There is an example sketch that came with your IDE called "Blink Without Delay". See if you can figure out how that works. You need exactly the same approach to this.
Delta_G:
There is an example sketch that came with your IDE called "Blink Without Delay". See if you can figure out how that works. You need exactly the same approach to this.
unsigned long previousmillis = 0;
int BlinkPin = 13;
void Blink()
{
if ((millis() - previousmillis) > 15000) //if 15sec left since last blink this will be execute
{
digitalWrite(BlinkPin, !digitalRead(BlinkPin)); //The BlinkPin will ever switched to the opposite of the current state
previousmillis = millis(); //store the current millis to a global unsigned long value
}
}
if ((millis() - previousmillis) > 15000) //if 15sec left since last blink this will be execute
{
digitalWrite(BlinkPin, !digitalRead(BlinkPin)); //The BlinkPin will ever switched to the opposite of the current state
previousmillis = millis(); //store the current millis to a global unsigned long value
}
}
Awesome. Thanks again. Just what I was looking for.