I’m trying to use the millisDelay feature to generate programmed delays but I get compiler errors. I am using the published example from Arduino as my test on the Arduino NANO board.
#include "millisDelay.h"
int led = 13;
millisDelay ledDelay;
void setup() {
pinMode(led, OUTPUT); // initialize the digital pin as an output.
digitalWrite(led, HIGH); // turn led on
ledDelay.start(10000); // start a 10sec delay
}
void loop() {
// check if delay has timed out
if (ledDelay.justFinished()) {
digitalWrite(led, LOW); // turn led off
Serial.println("Turned LED Off");
}
// Other loop code here . . .
Serial.println("Run Other Code");
}
I get the following errors among others:
undefined reference to millisDelay::millisDelay()' In function setup':
Time_Test/Time_Test.ino:9: undefined reference to `millisDelay::start(unsigned long)'
Then I'd say you didn't install the library properly.
The results here after installing millisDelay and compiling your sketch:
arduino-cli compile -b arduino:avr:nano:cpu=atmega328 --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Nano/test)
Sketch uses 1914 bytes (6%) of program storage space. Maximum is 30720 bytes.
Global variables use 228 bytes (11%) of dynamic memory, leaving 1820 bytes for local variables. Maximum is 2048 bytes.
Used library Version Path
millisDelay 1.3 /home/me/Documents/sketchbook/libraries/millisDelay-master
Used platform Version Path
arduino:avr 1.8.3 /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3
Compilation finished successfully.
Thanks for your follow up. I found that if I changed the #include "millisDelay.h" (local directory) to #include <millisDelay.h>, everything compiled correctly.
Thanks for the help.
If you want to use a local copy of the library (why ?) then you need at least the .h and .cpp files
Unless you have a good reason to use a local copy then delete the .h file to avoid confusion and use the library installed in the libraries folder of your sketchbook as you are now