0
0
Arduinoprogramming~20 mins

SD card module wiring in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SD Card Wiring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output when reading a file from SD card?

Consider this Arduino code snippet that reads from a file on an SD card. What will be printed on the Serial Monitor?

Arduino
#include <SD.h>
const int chipSelect = 10;
void setup() {
  Serial.begin(9600);
  if (!SD.begin(chipSelect)) {
    Serial.println("Initialization failed!");
    return;
  }
  File dataFile = SD.open("test.txt");
  if (dataFile) {
    while (dataFile.available()) {
      Serial.write(dataFile.read());
    }
    dataFile.close();
  } else {
    Serial.println("Error opening test.txt");
  }
}
void loop() {}
AInitialization failed!
BHello World!
CError opening test.txt
DNo output
Attempts:
2 left
💡 Hint

Check if the SD card is properly initialized and the file exists.

🧠 Conceptual
intermediate
1:00remaining
Which Arduino pin is commonly used for CS (Chip Select) in SD card wiring?

When wiring an SD card module to an Arduino Uno, which pin is most commonly used for the CS (Chip Select) signal?

APin A0
BPin 13
CPin 10
DPin 7
Attempts:
2 left
💡 Hint

Look for the default CS pin used in Arduino SD examples.

🔧 Debug
advanced
2:00remaining
Why does this SD card initialization code fail?

Look at this Arduino code snippet. It fails to initialize the SD card. What is the most likely cause?

Arduino
#include <SD.h>
const int chipSelect = 4;
void setup() {
  Serial.begin(9600);
  if (!SD.begin(chipSelect)) {
    Serial.println("Initialization failed!");
    return;
  }
  Serial.println("Initialization done.");
}
void loop() {}
AThe loop function is empty
BThe Serial baud rate is too low
CThe SD library is not included properly
DPin 4 is not the correct CS pin for the SD card wiring
Attempts:
2 left
💡 Hint

Check if the chipSelect pin matches the wiring.

📝 Syntax
advanced
1:30remaining
What error does this SD card wiring code produce?

What error will this Arduino code produce when compiled?

Arduino
#include <SD.h>
const int chipSelect = 10;
void setup() {
  Serial.begin(9600);
  if (!SD.begin(chipSelect)) {
    Serial.println("Failed");
  }
}
void loop() {}
ASyntaxError: missing semicolon after 'const int chipSelect = 10'
BTypeError: SD.begin expects a boolean argument
CRuntimeError: SD card not found
DNo error, code compiles and runs
Attempts:
2 left
💡 Hint

Look carefully at the line declaring chipSelect.

🚀 Application
expert
1:30remaining
How many SPI pins are used to wire an SD card module to Arduino Uno?

When wiring an SD card module to an Arduino Uno, how many SPI pins are connected (excluding power and ground)?

A4 pins: MOSI, MISO, SCK, CS
B3 pins: MOSI, MISO, SCK
C2 pins: MOSI and MISO only
D5 pins: MOSI, MISO, SCK, CS, and RESET
Attempts:
2 left
💡 Hint

Remember the SPI bus plus the chip select pin.