Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a function named blinkLED.
Arduino
void [1]() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than
blinkLED.Misspelling the function name.
✗ Incorrect
The function is named
blinkLED. This name matches the function definition and usage.2fill in blank
mediumComplete the code to call the function blinkLED inside loop().
Arduino
void loop() {
[1]();
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function that does not exist.
Forgetting the parentheses after the function name.
✗ Incorrect
The function
blinkLED is called inside loop() to blink the LED repeatedly.3fill in blank
hardFix the error in the function definition by completing the return type.
Arduino
[1] blinkLED() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a return type other than
void when no value is returned.Omitting the return type completely.
✗ Incorrect
The function does not return any value, so its return type should be
void.4fill in blank
hardFill in the blank to create a function that takes an integer parameter times and blinks the LED that many times.
Arduino
void blinkLED([1] times) { for (int i = 0; i < times; i++) { digitalWrite(LED_BUILTIN, HIGH); delay(500); digitalWrite(LED_BUILTIN, LOW); delay(500); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
void as a parameter type.Using a floating-point type like
float when an integer is needed.✗ Incorrect
The parameter
times is an integer, so its type should be int.5fill in blank
hardFill in the blanks to call blinkLED with the argument 3 inside loop().
Arduino
void loop() {
[1]([2]);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a wrong function name.
Passing the argument without parentheses.
✗ Incorrect
The function
blinkLED is called with the argument 3 to blink the LED three times.