Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start serial communication for data logging.
Arduino
void setup() {
Serial.begin([1]);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a baud rate too slow for efficient data logging.
✗ Incorrect
115200 is a common baud rate for fast and reliable serial communication in Arduino data logging.
2fill in blank
mediumComplete the code to write sensor data to the serial monitor.
Arduino
void loop() {
int sensorValue = analogRead(A0);
Serial.[1](sensorValue);
delay(1000);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Serial.print without new lines, causing cluttered output.
✗ Incorrect
Serial.println sends data followed by a new line, making logs easier to read line by line.
3fill in blank
hardFix the error in the code to correctly open the SD card for logging.
Arduino
#include <SD.h> const int chipSelect = 10; void setup() { if (!SD.[1](chipSelect)) { Serial.println("SD card failed or not present"); return; } Serial.println("SD card initialized."); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using open() or init() which are not valid SD library methods.
✗ Incorrect
SD.begin() initializes the SD card and must be called with the chip select pin.
4fill in blank
hardFill both blanks to write data to a file on the SD card.
Arduino
File dataFile = SD.[1]("log.txt", [2]); if (dataFile) { dataFile.println("Sensor data"); dataFile.close(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FILE_READ when trying to write data.
✗ Incorrect
Use SD.open() with FILE_WRITE to open a file for writing data.
5fill in blank
hardFill all three blanks to create a dictionary-like structure for logged data.
Arduino
struct DataEntry {
int [1];
float [2];
char [3][20];
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong data types or confusing variable names.
✗ Incorrect
This struct holds an integer id, a float temperature, and a char array timestamp for logging.