billli
Posts: 3
Joined: Wed Sep 17, 2014 3:55 am

GPIO.PUD_DOWN vs GPIO.PUD_UP

Thu Sep 18, 2014 4:08 am

Hi all:

I am a hardware noob, and was wondering what exactly does PUD_DOWN vs PUD_UP do?

I followed a PIR sensor tutorial and it used GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_UP)

Thanks

User avatar
B.Goode
Posts: 9226
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: GPIO.PUD_DOWN vs GPIO.PUD_UP

Thu Sep 18, 2014 5:54 am

This is what the author of the RPi.GPIO package has to say:

http://sourceforge.net/p/raspberry-gpio ... ki/Inputs/

User avatar
joan
Posts: 14652
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO.PUD_DOWN vs GPIO.PUD_UP

Thu Sep 18, 2014 7:07 am

An input gpio will float between 0 and 1 if it's not connected to a voltage.

The pull-up/downs supply that voltage so that the gpio will have a defined value UNTIL overridden by a stronger force.

You should set a pull-down (to 0) when you expect the stronger force to pull it up to 1.

You should set a pull-up (to 1) when you expect the stronger force to pull it down to 0.

Otherwise the gpio will not change state and you'll never know about the external event.

MasterC
Posts: 5
Joined: Sun Aug 16, 2015 4:58 am

Re: GPIO.PUD_DOWN vs GPIO.PUD_UP

Tue Oct 04, 2016 4:46 am

joan wrote:An input gpio will float between 0 and 1 if it's not connected to a voltage.

The pull-up/downs supply that voltage so that the gpio will have a defined value UNTIL overridden by a stronger force.

You should set a pull-down (to 0) when you expect the stronger force to pull it up to 1.

You should set a pull-up (to 1) when you expect the stronger force to pull it down to 0.

Otherwise the gpio will not change state and you'll never know about the external event.
Thank you! This is probably the best plain English response for what this does that I've found.

Return to “Beginners”