Control time library.
hi,
i'd ask whether knows library manage times.
for example, write code:
it'd easier library expresion:
our sketchs less tedious manage.
thanks.
i'd ask whether knows library manage times.
for example, write code:
code: [select]
unsigned long previousmilis;
int time = 1000;
setup {previousmilis= millis();}
loop {if(millis() - previousmillis > time) {previousmillis = millis();}}
it'd easier library expresion:
code: [select]
timelibrary mytime;
int time = 1000;
loop {if(mytime.check(time)) {}}
our sketchs less tedious manage.
thanks.
can made 1 of problems such function has function call overhead may or may not affect program flow. millis() not bad, micros story quite different.
the code function this.
have fun
the code function this.
code: [select]
boolean checktimeelapsedsincelastcall(unsigned long t) // shorter name possible ;)
{
static unsigned long prev = 0;
unsigned long = millis();
if (now - prev >= t)
{
prev = now;
return true;
}
return false;
}
have fun
Arduino Forum > Using Arduino > Programming Questions > Control time library.
arduino
Comments
Post a Comment