Go Down

Topic: SD not declared in this scope (Read 669 times) previous topic - next topic

Loren

h
Code: [Select]

#ifndef Card_h
#define Card_h

#include "Arduino.h"
#include <SD.h>"

class Card{

public:
void init();

private:
  int CS_pin;
};



#endif


source:

Code: [Select]
#include "Arduino.h"
#include "Card.h"

void Card::init(){

pinMode(CS_pin, OUTPUT);
if(!SD.begin(CS_pin)){
    Serial.println("Card Failed");
    return;
  }
  Serial.println("Card Ready");

 
}


I've read some web articles describing how to write libraries and I seem to be consistently failing at making this work.  I wrote a single sketch to see if I could read some info off of a SD card.  When I start to try and write a library to accomplish the task I get the error:

Code: [Select]
Card.cpp:9: error: 'SD' was not declared in this scope
  can someone explain why this doesn't work?

Thanks,

Loren

PaulS

We need to see your sketch, too. I'm guessing, though, that it does not include SD.h. It needs to.

MarkT

Code: [Select]
#include <SD.h>"


Syntax error...?
[ I won't respond to messages, use the forum please ]

Loren


We need to see your sketch, too. I'm guessing, though, that it does not include SD.h. It needs to.


Yep that was it.  Thanks again


Go Up