0
0
Arduinoprogramming~10 mins

CSV format data logging 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 open the file for writing in CSV format.

Arduino
File dataFile = SD.open([1], FILE_WRITE);
Drag options to blanks, or click blank then click option'
A"data.txt"
B"data.csv"
C"log.csv"
D"log.txt"
Attempts:
3 left
💡 Hint
Common Mistakes
Using .txt extension instead of .csv
Forgetting quotes around file name
2fill in blank
medium

Complete the code to write a comma separator between values in CSV.

Arduino
dataFile.print(sensorValue); dataFile.print([1]); dataFile.println(temperature);
Drag options to blanks, or click blank then click option'
A" "
B";"
C","
D"\n"
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolon instead of comma
Using newline instead of comma
3fill in blank
hard

Fix the error in the code to close the file after writing data.

Arduino
dataFile.[1]();
Drag options to blanks, or click blank then click option'
Astop
Bflush
Cend
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using flush instead of close
Using end or stop which do not exist
4fill in blank
hard

Fill both blanks to write a CSV header line with columns 'Time' and 'Value'.

Arduino
dataFile.print([1]); dataFile.print([2]); dataFile.println();
Drag options to blanks, or click blank then click option'
A"Time,"
B"Value"
C"Value,"
D"Time"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping column order
Missing comma after first column
5fill in blank
hard

Fill all three blanks to write sensor data with timestamp in CSV format.

Arduino
dataFile.print([1]); dataFile.print([2]); dataFile.println([3]);
Drag options to blanks, or click blank then click option'
Amillis()
B","
CsensorValue
DanalogRead(A0)
Attempts:
3 left
💡 Hint
Common Mistakes
Using analogRead directly instead of sensorValue variable
Missing comma separator