0
0
Arduinoprogramming~10 mins

Reading data from SD card in Arduino - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to include the SD library.

Arduino
#include [1]
Drag options to blanks, or click blank then click option'
A<SD.h>
B<SPI.h>
C<Wire.h>
D<EEPROM.h>
Attempts:
3 left
💡 Hint
Common Mistakes
Including SPI.h instead of SD.h
Forgetting to include any library
2fill in blank
medium

Complete the code to initialize the SD card in setup().

Arduino
if (!SD.[1](4)) {
  Serial.println("Initialization failed!");
  return;
}
Drag options to blanks, or click blank then click option'
Ainit
Bopen
Cstart
Dbegin
Attempts:
3 left
💡 Hint
Common Mistakes
Using SD.init() instead of SD.begin()
Using wrong pin number
3fill in blank
hard

Fix the error in opening the file for reading.

Arduino
File dataFile = SD.[1]("test.txt", FILE_READ);
Drag options to blanks, or click blank then click option'
AopenFile
Bread
Copen
DreadFile
Attempts:
3 left
💡 Hint
Common Mistakes
Using SD.read() which reads data, not opens file
Using non-existent functions like openFile
4fill in blank
hard

Fill both blanks to read and print each character from the file.

Arduino
while (dataFile.[1]()) {
  char c = dataFile.[2]();
  Serial.print(c);
}
Drag options to blanks, or click blank then click option'
Aavailable
Bread
Copen
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using open() or close() instead of available() or read()
Not checking if data is available before reading
5fill in blank
hard

Fill all three blanks to close the file and print a message.

Arduino
dataFile.[1]();
Serial.[2]("File closed.");
while (!Serial.[3]()) {}
Drag options to blanks, or click blank then click option'
Aclose
Bprintln
Cavailable
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to close the file
Using print() instead of println() for message
Not waiting for serial data before continuing