Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Bugs >> Software Bugs >> Controlling millis() function
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1222805631

Message started by ponckk on 09/30/08 at 20:13:51

Title: Controlling millis() function
Post by ponckk on 09/30/08 at 20:13:51
hello
does anyone know how to fix the bug that millis() has?, hen it gets to 32000 it colapses, and hense, the program doesnt run well after this.

please help

if(soltar ==false ){
   Serial.print(millis(), DEC);       // prints the value read
  Serial.print("M");
   if(millis() - activar > palpito){
     antes = 0;
     soltar = true;
   }
 }


//contact at ponckk@yahoo.com

Title: Re: Controlling millis() function
Post by barragan on 10/01/08 at 20:15:46
Could you please post Wiring version, OS, and complete code?

Title: Re: Controlling millis() function
Post by mga on 02/17/09 at 22:07:26
i have a similar problem

firmware 1.15
wiring 0018


Code:
void setup () {
 Serial.begin(9600);
}

void loop () {
 if (millis()-last_refresh>picture_time) {
   last_refresh = millis();
   Serial.println(last_refresh);
 }
 drawMatrix();
}


i removed irrelevant code. enough to say it all works well until the millisecond 32000. from that point on millis gives me negative values.

Title: Re: Controlling millis() function
Post by mga on 02/17/09 at 22:26:47
okay so i FINALLY figured out the deal

since millis can go up to (in theory) infinity, the number you associate it to must accept large values. i am now using unsigned long (this should give me about 50 days of continous "play")

i would suggest mentioning this in the reference for us newbies... i have been struggling with this thing for two days now.

- mga

Title: Re: Controlling millis() function
Post by barragan on 02/19/09 at 04:59:57
millis returns a long value, http://wiring.org.co/learning/reference/millis_.html
check also this: http://wiring.org.co/learning/examples/timer.html
for a full timer example.

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