Need help with timers

Hello. I am trying to understand how timers work, but they dont work for me. I am trying to create code where

if a<b , turn led on for 1 minute, if still a smaller than b keep led on for another minute. when a bigger than b turn led off for minimum 2 minutes.
I just cannot figure it out. Give me some advice please.

<<< theese symbols caused part of my text to dissapear :smiley:

BlynkTimer, while integrated into Blynk, is actually based on SimpleTimer. Here is the link for thatā€¦ lots of information on how it works.

Your solution will probably consist of both a Boolean and/or Comparison Operator check, and a timer routine (probably timeout would be best)ā€¦ so a bit of both basic Arduino code and Simple(Blynk)Timer code.

http://playground.arduino.cc/Code/SimpleTimer

This is where formatting helpsā€¦ the three backticks, fore and aft, of any strange characters can help make them visibleā€¦ as will (to some degree) the Preformatted Text </> button in your text entry menu.

Blynk - FTFC

Hi. I found this example: Timer. All timers are set up in the void setup(). Can i put line " timer.setTimeout(10000, OnceOnlyTask);" somewhere in my code to start this timer when i need, or that to be done somehow different?

Yes you can.

Those are typically the interval timersā€¦ they constantly run at set intervals throughout the entire scripts runtimeā€¦ thus the setup is a logical place to put them.

They could technically go anywhere, but then they might reset each time the code reaches themā€¦ effectively messing up the timing.

Other timers like timeouts can be placed whereverā€¦ just be aware that they donā€™t stop and wait for something to happen, so you have to be cognizant of timeframe when processing multiple timers to do advanced things.

E.g. Here is a crude ā€œOpen latch then flash LED x timesā€ routineā€¦ change one timer without accounting for the rest can mess everything up.

It uses both setTimeout and setTimer types:

//===== LATCH(Relay Sim) & LED PULSE - BLYNK Functions =====
BLYNK_WRITE(V40)  // Virtual button on V40 to activate Relay_LED pulses
{
  RLY_LED = param.asInt();
  if (RLY_LED == 1 && Flag == 0){
    Flag = 1;  // Keeps from allowing button press more then once while relay activated
    digitalWrite(30, HIGH); // Activate Relay
    timer.setTimeout(2000L, Relay2OFF);  // Deactivare Relay after 2 seconds
    timer.setTimer(2000L, LedON, 5);  // Pulse LED routine (LedON/LedOFF) 5 times
  }
}

void Relay2OFF()
{
  digitalWrite(30, LOW);
  Flag = 0;  // reset flag after relay disables
}

void LedON()
{
  digitalWrite(31, HIGH);  // Turn on LED
  timer.setTimeout(1000L, LedOFF);  // Run OFFLED routine once in 1 second
}

void LedOFF()
{
  digitalWrite(31, LOW);  // Turn off LED
}

Thank you all. It is not all fully clear, but i am getting closer to my achievement.