I am trying to write data to an SD card connected to a Teensy 4.1 using the port that's on the PCB (not an external micro SD module). I was trying to check if the Teensy is able to recognise that there is an SD card connected to it by uploading the following code:
It keeps saying that it is not able to initialise the SD card no matter what I use for Chip Select, I have tried setting chip select to the following: 4, 10, 'BUILTIN_SDCARD' but none of those worked.
What should I use for chip select? Or are there additional steps that need be performed for it to recognise the SD card? I have already formatted the card to FAT.
Code:
#include <SD.h>
#include <SPI.h>
const int CS = BUILTIN_SDCARD;
// const int CS = 10;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
if (SD.begin(CS)) {
Serial.println("SD card initialised");
}
else {
Serial.println("SD card initialisation failed");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
It keeps saying that it is not able to initialise the SD card no matter what I use for Chip Select, I have tried setting chip select to the following: 4, 10, 'BUILTIN_SDCARD' but none of those worked.
What should I use for chip select? Or are there additional steps that need be performed for it to recognise the SD card? I have already formatted the card to FAT.