Teensy 3.6 and SD card Error

Jframe64

New member
Hi, this is my first post so please forgive, but ive been having a problem with using the SD library with the teensy 3.6. Here is the code

#include <SD.h>
#include <SPI.h>
int chipSelect = BUILTIN_SDCARD;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

Serial.print("Initializing SD card...");

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
while (1) {
// No SD card, so don't do anything more - stay stuck here
}
}


}

void loop() {
// put your main code here, to run repeatedly:
File dataFile = SD.open("Hello_World.txt", FILE_WRITE);

if (dataFile) {
dataFile.print("Hello World");
dataFile.close();
Serial.print("Data Transferred ");

} else {
// if the file isn't open, pop up an error:
Serial.println("error opening Hello_World.txt");
}
delay(5);

}

My error is that BUILTIN_SDCARD was not declared in this scope. Can someone tell me what I am doing wrong?
Thanks
 
These are my error messages:

Datalog_Test:3: error: 'BUILTIN_SDCARD' was not declared in this scope
int chipSelect = BUILTIN_SDCARD;
^
Multiple libraries were found for "SD.h"
Used: /Users/jackframe/Documents/Arduino/libraries/SD
Not used: /private/var/folders/q0/f692vy793hd6kjlxn7nf9phr0000gn/T/AppTranslocation/CFBF12E0-3824-4579-912B-7D8FC3C22C4F/d/Teensyduino 2.app/Contents/Java/libraries/SD
Not used: /private/var/folders/q0/f692vy793hd6kjlxn7nf9phr0000gn/T/AppTranslocation/CFBF12E0-3824-4579-912B-7D8FC3C22C4F/d/Teensyduino 2.app/Contents/Java/hardware/teensy/avr/libraries/SD
Not used: /Users/jackframe/Documents/Arduino/libraries/SD-Juse_Use_SdFat
'BUILTIN_SDCARD' was not declared in this scope
 
That code compiles for me. Make sure that you have selected the Teensy 3.6. If you're using the Arduino IDE it is selected in Tools|Boards and when you have a board selected, the very bottom line in the IDE window will show which board is selected.

Pete
P.S. I'm using Windows
 
Screen Shot 2022-01-01 at 10.52.07 AM.jpg
It says that I am using teensy 3.6 in that bottom line but it still doesn't accept BUILTIN_SDCARD.
 
You're using a very old version of the IDE and, presumably, TeensyDuino.
Windows IDE is version 1.8.19 and TeensyDuino is 1.56

Pete
 
The error messages suggest that you aren't using Windows. Download the latest version of Arduino IDE for your OS and the latest Teensyduino and then install them.

Pete
 
Back
Top