Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arduino custom library error when compiling delay()

I am trying to write an adruino library but keep getting hung up on errors requiring me to include header files. I have run into one that I can't find the header file for. I keep getting the error:

...file.cpp:23: error: 'delay' was not declared in this scope

Line 23 of my .cpp file is:

delay(10);

Any help would be greatly appreciated. Thank you.

like image 927
Pierce Barney Avatar asked Dec 21 '11 16:12

Pierce Barney


2 Answers

If you are using a version of the Arduino software prior to 1.0 (with a version number of the form 00XY, e.g. 0023) you need to include WProgram.h in your .cpp files.

If you are using 1.0 or above include Arduino.h instead (the header file was renamed in that version).

like image 197
helloworld922 Avatar answered Dec 04 '22 14:12

helloworld922


change

  #include "WProgram.h"

to

  #if defined(ARDUINO) && ARDUINO >= 100
      #include "Arduino.h"
    #else
      #include "WProgram.h"
    #endif

in the offending .h header file

like image 36
Hayden Thring Avatar answered Dec 04 '22 14:12

Hayden Thring