0
0
Arduinoprogramming~10 mins

Code organization with functions 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 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'
AblinkLED
BstartBlink
CledBlink
DflashLED
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than blinkLED.
Misspelling the function name.
2fill in blank
medium

Complete the code to call the function blinkLED inside loop().

Arduino
void loop() {
  [1]();
}
Drag options to blanks, or click blank then click option'
AstartBlink
Bdelay
CdigitalWrite
DblinkLED
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function that does not exist.
Forgetting the parentheses after the function name.
3fill in blank
hard

Fix 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'
Avoid
Bboolean
Cint
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using a return type other than void when no value is returned.
Omitting the return type completely.
4fill in blank
hard

Fill 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'
Aboolean
Bvoid
Cint
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using void as a parameter type.
Using a floating-point type like float when an integer is needed.
5fill in blank
hard

Fill 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'
AdigitalWrite
B3
CblinkLED
Ddelay
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a wrong function name.
Passing the argument without parentheses.