Skip to content

Examples for SD card use contains bug. #3775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ShakeyJake opened this issue Sep 10, 2015 · 1 comment
Closed

Examples for SD card use contains bug. #3775

ShakeyJake opened this issue Sep 10, 2015 · 1 comment
Milestone

Comments

@ShakeyJake
Copy link

The example code here: https://www.arduino.cc/en/Tutorial/Files needs pin 10 set high before you call SD.begin(4) or else initialization fails.

This code works:

// while (!Serial) {
// ; // wait for serial port to connect. Needed for Leonardo only
// }
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);

Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.

if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}

This code does not:

Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);

if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

@facchinm
Copy link
Member

Hi @ShakeyJake , the issue you are reporting is well known and it means that you are using an older version of the library.
The bug has been fixed with #2974. Updating the AVR core using the Board Manager will solve the issue.
By the way, if you open the bundled SD examples (from inside the menu) instead than website Reference (which is always in sync with master branch) digitalWrite(10, HIGH); should be there

@ffissore ffissore modified the milestone: Release 1.6.6 Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants