Intro

picture 1

NameDescription
CDCard detect *
DOSPI data output (MISO)
GNDGround
SCKSPI clock
VCCVoltage supply
DISPI data input (MOSI)
CSChip select

Arduino Example

Arduino Example

When you start the simulation, Wokwi creates a FAT16 file system and attaches it to the microSD card. By default, Wokwi copies all your project files into the microSD card.

SD Card PinArduino Uno Pin
SCK13
DO (MISO)12
DI (MOSI)11
CS10
# From https://wokwi.com/projects/310692660849410626
#include "SdFat.h"
 
#define SPI_SPEED SD_SCK_MHZ(4) // SPI speed 4 MHz
#define CS_PIN 10
 
SdFat sd; // create a sdFat object to interface with the SD card (FAT16/FAT32)
 
void setup() {
  Serial.begin(115200);
  if (!sd.begin(CS_PIN, SPI_SPEED)) { // Initialize SD card
    if (sd.card()->errorCode()) {
      Serial.println("SD initialization failed.");
    } else if (sd.vol()->fatType() == 0) {
      Serial.println("Can't find a valid FAT16/FAT32 partition.");
    } else {
      Serial.println("Can't determine error type");
    }
    return;
  }
 
  
  Serial.println("Files on card:");
  Serial.println("   Size    Name");
 
// Print files with their size (recursively)
  sd.ls(LS_R | LS_SIZE);
}
 
void loop() {
}