D. Missing parentheses after function name in declaration
Solution
Step 1: Check function declaration syntax
The function blinkLED is declared without parentheses, which is invalid.
Step 2: Confirm correct syntax
Function declarations must have parentheses even if no parameters: void blinkLED() { ... }.
Final Answer:
Missing parentheses after function name in declaration -> Option D
Quick Check:
Function declaration needs () [OK]
Hint: Always include () after function name in declaration [OK]
Common Mistakes:
Forgetting parentheses in function declaration
Adding semicolon after function call (not needed)
Misunderstanding digitalWrite usage
5. You want to create a function setLED that turns an LED on or off based on a parameter. Which of these function definitions correctly uses a parameter to control the LED state on pin 13?
hard
A. void setLED(int state) { digitalWrite(13, state); }
B. void setLED() { digitalWrite(13, HIGH); }
C. int setLED(int state) { return digitalWrite(13, state); }
D. void setLED(boolean state) { digitalWrite(13, !state); }
Solution
Step 1: Understand parameter type for LED state
LED state is usually HIGH or LOW, which are integers in Arduino.
Step 2: Check function that uses parameter correctly
void setLED(int state) { digitalWrite(13, state); } takes an int parameter and passes it directly to digitalWrite on pin 13.
Step 3: Evaluate other options
B ignores parameter, C wrongly returns digitalWrite result, D inverts boolean state which may confuse usage.
Final Answer:
void setLED(int state) { digitalWrite(13, state); } -> Option A
Quick Check:
Parameter controls LED state directly [OK]
Hint: Use int parameter for HIGH/LOW and pass to digitalWrite [OK]
Common Mistakes:
Returning digitalWrite result (void function expected)
Ignoring parameter and hardcoding LED state
Inverting boolean state unintentionally
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.