C. The mode parameter in pinMode() should not be in quotes.
D. digitalWrite() cannot be used in setup().
Solution
Step 1: Check pinMode() parameter types
The mode parameter must be a constant like OUTPUT without quotes. Using quotes makes it a string, causing a compile error.
Step 2: Verify other parts
Pin 13 is valid. digitalWrite() can be used in setup(). Serial.begin() is not required here.
Final Answer:
The mode parameter in pinMode() should not be in quotes. -> Option C
Quick Check:
pinMode mode no quotes = D [OK]
Hint: Use OUTPUT without quotes in pinMode() [OK]
Common Mistakes:
Putting mode in quotes
Thinking pin 13 is invalid
Believing digitalWrite() can't be in setup()
5. You want to connect a push button to pin 2 and read its state without an external resistor. Which pinMode() setting should you use to ensure the pin reads HIGH when the button is not pressed?
hard
A. pinMode(2, OUTPUT);
B. pinMode(2, INPUT_PULLUP);
C. pinMode(2, INPUT);
D. pinMode(2, INPUT_PULLDOWN);
Solution
Step 1: Understand button wiring without external resistor
Without an external resistor, the internal pull-up resistor must be enabled to keep the pin HIGH when the button is not pressed.
Step 2: Choose correct pinMode()
Using INPUT_PULLUP activates the internal pull-up resistor. INPUT alone leaves the pin floating. OUTPUT is wrong for reading. INPUT_PULLDOWN is not standard on Arduino.
Final Answer:
pinMode(2, INPUT_PULLUP); -> Option B
Quick Check:
Use INPUT_PULLUP for internal resistor = A [OK]
Hint: Use INPUT_PULLUP to avoid external resistor on button pin [OK]
Common Mistakes:
Using INPUT without pull-up resistor causes floating pin
Trying OUTPUT mode to read button
Assuming INPUT_PULLDOWN exists on all Arduino boards