Recall & Review
beginner
What does reading a digital input pin state mean in embedded C?
It means checking if the pin is at a HIGH (1) or LOW (0) voltage level to know if a button or sensor is ON or OFF.
Click to reveal answer
beginner
Which function is commonly used to read a digital input pin state in embedded C?
The function
digitalRead(pin) is used to read the state of a digital input pin, returning HIGH or LOW.Click to reveal answer
beginner
Why do we need to set a pin as INPUT before reading its state?
Setting a pin as INPUT tells the microcontroller to listen to the pin's voltage level instead of sending voltage out.
Click to reveal answer
beginner
What values can a digital input pin return when read?
It can return either HIGH (usually 1 or voltage level) or LOW (0 volts), representing ON or OFF states.
Click to reveal answer
intermediate
How can you avoid reading a floating input pin state?
Use a pull-up or pull-down resistor to fix the pin state when no button is pressed, preventing random readings.
Click to reveal answer
What does
digitalRead(pin) return when the input pin is connected to ground?✗ Incorrect
When the pin is connected to ground, the voltage is 0, so digitalRead returns LOW.
Before reading a digital input pin, what must you do?
✗ Incorrect
You must set the pin as INPUT to read its state correctly.
What problem does a floating input pin cause?
✗ Incorrect
A floating pin can randomly read HIGH or LOW because it is not connected to a fixed voltage.
Which resistor helps stabilize a digital input pin state?
✗ Incorrect
Both pull-up and pull-down resistors can stabilize the pin by fixing it to HIGH or LOW when not driven.
If
digitalRead(pin) returns HIGH, what does it mean?✗ Incorrect
HIGH means the pin voltage is close to the supply voltage, usually 3.3V or 5V.
Explain how to read a digital input pin state in embedded C and why setting pin mode is important.
Think about how the microcontroller knows if a button is pressed.
You got /4 concepts.
Describe what a floating input pin is and how to prevent it when reading digital inputs.
Imagine a wire not connected to anything and how it behaves.
You got /4 concepts.