Issues with pausing a BlinkWithoutDelay time


the code runs when button pressed. stops running, should, when button pressed again. however, when button pressed again start, program reads continuously running currentmillis timer , updates targetcount when should have been "paused".

i want keep time button2counter odd number. when button2counter becomes again, add time elapsed while counter odd previousmillis variable. way, program delay increasing targetcount until targettime has elapsed.

why isn't 'pausing' should?


code: [select]
unsigned long currentmillis = millis();
 


  if (((button2counter % 2) == 0)) {
    previousmillis = (previousmillis + elapsedmillis);
    if (currentmillis - previousmillis >= targettime) {
      if (m == 0) {         //first iteration not increment until time elapses
        previousmillis = currentmillis;
        m++;
      }
      else {
        previousmillis = currentmillis;
        elapsedmillis = 0;
        // increase target count
        targetcount++;   //delay count start @ 0
      }
    }
  }
  else{
        elapsedmillis = millis();
  }

you need post complete program.

the demo several things @ time extended example of bwod , may understanding.

...r


Arduino Forum > Using Arduino > Programming Questions > Issues with pausing a BlinkWithoutDelay time


arduino

Comments

Popular posts from this blog

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading