Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Programming Questions & Help >> Syntax >> Millis() reset?
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1249841938

Message started by Titus on 08/09/09 at 18:18:58

Title: Millis() reset?
Post by Titus on 08/09/09 at 18:18:58
Hi Barragan,

I'm building a 3x3x3 led cube, controlling it with 12 i/o pins.
To achieve this I had to multiplex a lot.
During writing the code I stumbled across a problem:

I wondered, is there a way to reset the Millis() function?
Because I want to loop some sequences involving multiplexing leds, so I'd basically wanted to do the following:

void loop()
{
*loop this for 4 seconds*
*loop this for 2 seconds*
*loop this for 3 seconds*
}

where every "* loop this etc*" consists of quite a few actions that run really fast(turn leds on for 1 ms and then off, because of the multiplexing)

while( Millis() < 4000)
{
things to loop
}
*RESET Millis()*
while ( Millis() < 2000)
{
etc


This way I would loop a sequence of loops.
I know it sounds strange, but is there a way to reset the Millis() function. If that would be possible it would be great!

I don't mind changing things in the source code or what ever :D

Thanks!!!

Titus

P.S. Kars and I got second on the world championships robocup junior soccer with our wiring soccer robots!
A website will soon be online for the exhibition!

Title: Re: Millis() reset?
Post by barragan on 08/10/09 at 16:50:34
hi Titus this can be done in this way using a variable to keep your time, so the variable can be reset when you need it: http://wiring.org.co/learning/examples/timer.html

Title: Re: Millis() reset?
Post by Titus on 08/10/09 at 17:16:52
I knew I should have thought of that. Thanks.


Title: Re: Millis() reset?
Post by mga on 11/12/10 at 02:10:01
The link referenced changed. New location: http://wiring.org.co/learning/basics/timer.html

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.