Pages: [1]   Go Down
Author Topic: Creating own library, how to import SPI....  (Read 1705 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I am developing my own library which uses the SPI interface.  When I had all the library code in my sketch it compiled fine.
I decided to move the sketch code to a library and have created the appropriate folder,cpp,h files under the Libraries folder.

My library cpp file includes at the top


#include <SPI.h>

But when I try to compile my sketch that uses the new library I the following error:


error: SPI.h: No such file or directory


error from the library cpp file.

I know if I include <SPI.h> at the top of the sketch it and remove from the library I get a different error:

error: 'SPI' was not declared in this scope


How do I import the SPI library into my own library?

Any help is appreciated
Thanks
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 210
Posts: 13039
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try...

Code:
#include "SPI.h"
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 642
Posts: 50384
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I know if I include <SPI.h> at the top of the sketch it and remove from the library I get a different error
The SPI.h file needs to be included in the source file AND the sketch. It is not an either/or proposition.
Logged

Pages: [1]   Go Up
Jump to: