How do you reset an onboard timer??


hi all, i'm having trouble resetting timer. there not interrupt or hardware of kind. tell me @ blinkwithoutdelay, it's not working quite way want to. let me attempt explain way want work. timer not in loop(). rather, started when sensor comes within distance of object. once within distance separate function called, starting timer.

here sample timer in loop, no reset of timer :(

code: [select]
unsigned long prevtime=0;
unsigned long curtime=0;
const int valinter = 750;

void setup()  {
  serial.begin(9600);
}

void loop()  {
  serial.println(curtime);
  curtime=millis();
  if( curtime > (prevtime + valinter) )  {
    curtime=curtime-valinter;
    return;
  }
}


timer resets once , keeps going on diesel train second time. how keep resetting after 3/4 of second?

i looking @ topics before posting, , @awol had interesting point made sense. talking 'offsetting' timer rather 'resetting' per say. when setting millis() variable zero, read zeroes after if statement true.

not good.

attempted 'offsetting' in code above , again listed here:

code: [select]
curtime=curtime-valinter;


Arduino Forum > Using Arduino > Programming Questions > How do you reset an onboard timer??


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support