Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include the SD card library.
Arduino
#include <[1]>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including SPI.h instead of SD.h
Forgetting to include any library
✗ Incorrect
The SD.h library is needed to work with the SD card module.
2fill in blank
mediumComplete the code to define the chip select pin for the SD card module.
Arduino
const int chipSelect = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin 10 which is for SPI but not always CS
Using pin 13 which is the built-in LED pin
✗ Incorrect
Pin 4 is commonly used as the chip select pin for SD card modules on Arduino.
3fill in blank
hardFix the error in the SD card initialization code.
Arduino
if (!SD.[1](chipSelect)) { Serial.println("Initialization failed!"); return; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
init() or start() which do not existUsing
open() which is for files✗ Incorrect
The correct function to initialize the SD card is begin().
4fill in blank
hardFill both blanks to create a file and write text to it.
Arduino
File myFile = SD.[1]("test.txt", [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
FILE_READ when writing is neededUsing
begin as a function to open files✗ Incorrect
Use SD.open() with FILE_WRITE to create and write to a file.
5fill in blank
hardFill all three blanks to write text to the file and close it.
Arduino
myFile.[1]("Hello, SD card!"); myFile.[2](); Serial.[3]("File written successfully.");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
println() to write to the fileForgetting to close the file
✗ Incorrect
Use print() to write text, close() to close the file, and println() to print a message to Serial.