Bird
Raised Fist0
Embedded Cprogramming~5 mins

Writing HIGH and LOW to output pins in Embedded C - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What does writing HIGH to an output pin mean in embedded C?
Writing HIGH sets the output pin voltage to a high level, usually 5V or 3.3V, turning the pin ON or activating connected devices like LEDs.
Click to reveal answer
beginner
How do you write LOW to an output pin in embedded C?
You write LOW by setting the pin's output register to 0, which sets the pin voltage to 0V, turning the pin OFF or deactivating connected devices.
Click to reveal answer
beginner
Which function is commonly used to set a pin HIGH or LOW in Arduino (embedded C)?
The function digitalWrite(pin, value) is used, where value can be HIGH or LOW to set the pin voltage accordingly.
Click to reveal answer
beginner
Why must a pin be set as OUTPUT before writing HIGH or LOW?
Pins default to input mode. Setting a pin as OUTPUT configures it to send voltage signals, allowing you to write HIGH or LOW to control devices.
Click to reveal answer
intermediate
What happens if you write HIGH to a pin configured as INPUT?
Writing HIGH to an INPUT pin usually enables the internal pull-up resistor, but does not drive the pin voltage high externally; the pin reads signals instead of sending them.
Click to reveal answer
What voltage level does writing HIGH to an output pin usually set?
A12V
B0V
CIt depends on the input signal
D5V or 3.3V
Which function sets a pin as output in Arduino embedded C?
AdigitalWrite(pin, OUTPUT)
BpinMode(pin, OUTPUT)
CsetPin(pin, OUTPUT)
DwritePin(pin, OUTPUT)
What does digitalWrite(pin, LOW) do?
ASets the pin voltage to 0V
BSets the pin voltage to 5V
CReads the pin voltage
DConfigures the pin as input
If a pin is not set as OUTPUT, what happens when you write HIGH to it?
ANo voltage is driven on the pin
BPin voltage goes to 5V
CPin voltage goes to 0V
DPin mode changes to OUTPUT automatically
Which of these is the correct way to turn on an LED connected to pin 13?
ApinMode(13, INPUT); digitalWrite(13, HIGH);
BdigitalWrite(13, HIGH); pinMode(13, OUTPUT);
CpinMode(13, OUTPUT); digitalWrite(13, HIGH);
DdigitalWrite(13, LOW); pinMode(13, OUTPUT);
Explain how to turn an output pin HIGH and LOW in embedded C and why setting pin mode matters.
Think about configuring the pin first, then sending voltage signals.
You got /4 concepts.
    Describe what happens if you try to write HIGH to a pin that is set as INPUT.
    Consider the difference between input and output pin modes.
    You got /4 concepts.

      Practice

      (1/5)
      1. Which function is used to set a pin as an output before writing HIGH or LOW to it?
      easy
      A. setPinMode(pin, HIGH)
      B. digitalWrite(pin, OUTPUT)
      C. pinMode(pin, OUTPUT)
      D. writePin(pin, OUTPUT)

      Solution

      1. Step 1: Understand pin configuration

        Before writing HIGH or LOW, the pin must be set as an output to control voltage.
      2. Step 2: Identify the correct function

        The function to set pin mode is pinMode(pin, OUTPUT), which configures the pin for output.
      3. Final Answer:

        pinMode(pin, OUTPUT) -> Option C
      4. Quick Check:

        Set pin as output = pinMode(pin, OUTPUT) [OK]
      Hint: Set pin mode with pinMode before writing HIGH or LOW [OK]
      Common Mistakes:
      • Using digitalWrite to set pin mode
      • Confusing HIGH/LOW with OUTPUT/INPUT
      • Forgetting to set pin mode before writing
      2. Which of the following is the correct syntax to turn pin 5 ON (HIGH) in embedded C?
      easy
      A. digitalWrite(5, 1);
      B. digitalWrite(5, ON);
      C. digitalWrite(5, OUTPUT);
      D. digitalWrite(5, HIGH);

      Solution

      1. Step 1: Identify the function to write pin state

        The function digitalWrite(pin, value) sets the pin voltage HIGH or LOW.
      2. Step 2: Use correct constants

        Use HIGH to turn the pin ON. The correct syntax is digitalWrite(5, HIGH);.
      3. Final Answer:

        digitalWrite(5, HIGH); -> Option D
      4. Quick Check:

        Turn pin ON = digitalWrite(pin, HIGH) [OK]
      Hint: Use HIGH constant, not ON or numbers, for clarity [OK]
      Common Mistakes:
      • Using ON instead of HIGH
      • Using OUTPUT instead of HIGH
      • Using numeric 1 instead of HIGH constant
      3. What will be the output state of pin 3 after running this code?
      pinMode(3, OUTPUT);
      digitalWrite(3, LOW);
      digitalWrite(3, HIGH);
      medium
      A. Pin 3 will be LOW
      B. Pin 3 will be HIGH
      C. Pin 3 will be in input mode
      D. Pin 3 will be undefined

      Solution

      1. Step 1: Set pin 3 as output

        The code sets pin 3 as output with pinMode(3, OUTPUT);.
      2. Step 2: Write LOW then HIGH to pin 3

        First, pin 3 is set LOW, then immediately set HIGH, so final state is HIGH.
      3. Final Answer:

        Pin 3 will be HIGH -> Option B
      4. Quick Check:

        Last digitalWrite sets pin state = HIGH [OK]
      Hint: Last digitalWrite sets the pin state [OK]
      Common Mistakes:
      • Assuming pin stays LOW after writing HIGH
      • Forgetting pinMode sets output mode
      • Thinking pin state is undefined without delay
      4. Identify the error in this code snippet:
      pinMode(7, OUTPUT);
      digitalWrite(7, HIGH)
      digitalWrite(7, LOW);
      medium
      A. Missing semicolon after digitalWrite(7, HIGH)
      B. pinMode should be called after digitalWrite
      C. HIGH and LOW are not valid constants
      D. Pin number 7 cannot be used

      Solution

      1. Step 1: Check syntax line by line

        The second line digitalWrite(7, HIGH) is missing a semicolon at the end.
      2. Step 2: Confirm other lines are correct

        pinMode(7, OUTPUT); and digitalWrite(7, LOW); are correct syntax.
      3. Final Answer:

        Missing semicolon after digitalWrite(7, HIGH) -> Option A
      4. Quick Check:

        Every statement must end with semicolon [OK]
      Hint: Check each line ends with a semicolon [OK]
      Common Mistakes:
      • Forgetting semicolon after function calls
      • Calling pinMode after digitalWrite
      • Misusing HIGH/LOW constants
      5. You want to toggle pin 10 ON and OFF every second in a loop. Which code snippet correctly sets pin 10 HIGH then LOW with a 1-second delay between states?
      hard
      A. pinMode(10, OUTPUT); digitalWrite(10, HIGH); delay(1000); digitalWrite(10, LOW); delay(1000);
      B. digitalWrite(10, HIGH); delay(1000); digitalWrite(10, LOW); delay(1000);
      C. pinMode(10, INPUT); digitalWrite(10, HIGH); delay(1000);
      D. pinMode(10, OUTPUT); digitalWrite(10, LOW); digitalWrite(10, HIGH);

      Solution

      1. Step 1: Set pin 10 as output

        Use pinMode(10, OUTPUT); to configure pin 10 for output.
      2. Step 2: Write HIGH, wait, then LOW, wait

        Use digitalWrite(10, HIGH); then delay(1000); to wait 1 second, then digitalWrite(10, LOW); and delay again.
      3. Final Answer:

        pinMode(10, OUTPUT); digitalWrite(10, HIGH); delay(1000); digitalWrite(10, LOW); delay(1000); -> Option A
      4. Quick Check:

        Set output, write states with delay between [OK]
      Hint: Always set pinMode before toggling with delays [OK]
      Common Mistakes:
      • Forgetting to set pinMode as OUTPUT
      • Missing delay between HIGH and LOW
      • Setting pinMode to INPUT instead of OUTPUT
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard