I am not getting clarity on how pull up, pull down, and GPIO values work.

If a pin is input and pull up, does it make the value 1?

If a pin is input and pull down, does it make the value 0?

If the above assumptions are wrong then what is missing in my understanding?

enter image description here

Image from the diagram on page 5 of this presentation.


1 Answer 1

  • When you set a pin to "input with pull-up" then read the input, you will get a "1" for the value.
  • When you set a pin to "input with pull-down" then read the input, you will get a "0" for the value.

This applies as long as nothing else is connected to the pin. When you connect something to the pin, then that something else can force the pin to a different value - that's kind of the point of it.

The pull-up or pull-down provides a default for the input when nothing is connected.

If you connect an input pin with a pull-up to ground, then current will flow out of the input to ground. It will be a very low current, likely less than one milliampere because the pull-up resistors are typically more than 10 kiloohms.

This really can be used to light LEDs when you don't have resistors handy to limit the current. More a sort of "party trick," though. It is exceedingly dim.

  • \$\begingroup\$ If a pin is input and pull up, does it mean the if I connect this pin to ground, current will sink from this pin to ground and if an led is connected it will light up? So actually the pin is behaving as output? \$\endgroup\$ Jan 27 at 11:26
  • \$\begingroup\$ It is not an output. It is an input. An input that will sink or source current through the resistance that is activated. \$\endgroup\$
    – Justme
    Jan 27 at 11:57
  • \$\begingroup\$ So if a pin is input and pull up (3.3V), then what can become an input here, 5V? What does input mean, to sink current into the pin? \$\endgroup\$ Jan 27 at 12:12
  • \$\begingroup\$ Just to give context, pull up means connecting to VDD, i.e. 3.3 V generally, then how the current is very low when it is connected to ground? Or VDD is very less compared to 3.3 V usually. \$\endgroup\$ Jan 27 at 12:20
  • \$\begingroup\$ For \$V_{DD}\$ = 3.3V and \$R_{PU}\$ = 10kΩ: when 0V is connected to the input, the current through the pull-up will be 330μA, which is sufficiently low. \$\endgroup\$
    – Velvel
    Jan 27 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.