Complete the code to get the current time in microseconds.
unsigned long currentTime = [1]();The micros() function returns the number of microseconds since the Arduino board began running the current program.
Complete the code to calculate elapsed time in microseconds.
unsigned long startTime = micros();
// some code here
unsigned long elapsed = [1]() - startTime;To measure elapsed time in microseconds, use micros() again and subtract the start time.
Fix the error in the code to correctly measure a 100 microsecond delay.
unsigned long start = micros(); while (micros() - start < [1]) { // wait }
The code waits until 100 microseconds have passed. The blank should be 100 to match the desired delay.
Fill both blanks to create a dictionary of words and their lengths, filtering words longer than 3 characters.
std::map<std::string, int> wordLengths; for (const auto& word : words) { if (word.length() [1] 3) { wordLengths[word] = [2]; } }
The condition checks if the word length is greater than 3. The length is assigned using word.size().
Fill all three blanks to create a map of uppercase words to their lengths, filtering words longer than 4 characters.
std::map<std::string, int> wordMap; for (const auto& word : words) { if (word.length() [1] 4) { std::string upperWord = [2]; wordMap[[3]] = word.length(); } }
The condition uses '<' to filter words shorter than 4 characters. The uppercase word is created by toUpperCase(word) and used as the key.
