I am trying to program a timer that can be reset/retriggered by a digital input. I stumbled upon the "elapsedMillis" library which seems like it would do just what I need. However, I cannot get anywhere with it. When I use the example code given at Arduino Playground - elapsedMillis Library
#include <elapsedMillis.h>
elapsedMillis timeElapsed; //declare global if you don't want it reset every time loop runs
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;
// delay in milliseconds between blinks of the LED
unsigned int interval = 1000;
// state of the LED = LOW is off, HIGH is on
boolean ledState = LOW;
void setup()
{
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
void loop()
{
if (timeElapsed > interval)
{
ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ...
digitalWrite(led, ledState);
timeElapsed = 0; // reset the counter to 0 so the counting starts over...
}
}
I get the following error when I try to compile the above code (yes, I did install the libary and it does show up):
Arduino: 1.5.3 (Windows XP), Board: "Arduino Duemilanove or Diecimila, ATmega328"
sketch_mar13a:3: error: 'global' does not name a type
sketch_mar13a.ino: In function 'void loop()':
sketch_mar13a:22: error: 'timeElapsed' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Can anyone tell me what the problem may be?
Thanks...arniep