PDA

View Full Version : ElpasedMillis doesn't seem to work



Phoebus
11-27-2012, 05:22 PM
Hello Everyone (and Hopefully Paul)

I tried the elapsedMills data type in the code below and it doesn't work. I'm using the teensy++2.0.
Any ideas what's happening?


//code starts here
// create elapsedMillis outside loop(), to
// retain its value each time loop() runs.

elapsedMillis sinceTest1;
elapsedMillis sinceTest2;
elapsedMillis sinceTest3;
void setup
{
Serial.begin(9600);
}

void loop() {
if (sinceTest1 >= 1000) {
sinceTest1 = sinceTest1 - 1000;
Serial.println("Test1 (1 sec)");
}
if (sinceTest2 >= 2700) {
sinceTest2 = sinceTest2 - 2700;
Serial.println(" Test2 (2.7 sec)");
}
if (sinceTest3 >= 1300) {
sinceTest3 = sinceTest3 - 1300;
Serial.println(" Test3 (1.3 sec)");
}
}

Rudy

Phoebus
11-27-2012, 05:39 PM
Oh and I should add the error message I get is:
sketch_nov27c:4: error: function definition does not declare parameters

PaulStoffregen
11-27-2012, 06:47 PM
The problem (probably) isn't elapsedMillis.

Change this:



void setup


to this:



void setup()

PaulStoffregen
11-27-2012, 10:54 PM
Also, please install the latest Teensyduino. It fixes a bug in reporting the line number for compiler errors.

Phoebus
11-28-2012, 01:17 PM
Thanks Paul, I feel like such an idiot (doh!)