0
votes

I'm creating a few classes for a project, which seems so specific that I don't want to keep in the libraries folder. They're mostly working, however, if I want to call any Arduino functions or consts, it will throw errors "is not declared in this scope".

sketch:

#include "MyClass.h"
void setup(){
}
void loop(){
}

MyClass.h

class MyClass{
    public:
        MyClass(int inp);
        int myFun();
};

MyClass.cpp

#include "MyClass.h"
#include <WProgram.h>

MyClass::MyClass(int inp){
    pinMode(13,HIGH);

}

error:

MyClass.cpp: 'HIGH','pinMode' is not declared in this scope.

It wouldn't happen if I put the libraries in libraries folder though. Wondering if there's a way to include arduino functions into sketch folder libraries?

2

2 Answers

0
votes

AFAIK there is no way to have yout libraries anywhere but in the Arduino-lib-folder. If using unix you could put your libs in your sketch folder and create a link to these libs in your Arduino-lib-folder with ln. Then you should also see them in your IDE

0
votes

Actually I just get it to work, by looking into another library :P instead of

 #include <WProgram.h>

We should use

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

Which is bad for backward compatibility as I think...

And it's not a problem regarding using libraries in sketch folder. There're some potential problems with sketch folder libraries however.