I'm struggling to understand pull-up and pull-down resistors

For digital circuits an input state is considered high or low. HIGH=5v LOW=0v

As an example think of a scenario where you push a button to trigger an event. A garage door opener, turn on an LED, trigger sound etc.

You've designed your circuit so when you push this button you send a 5v signal to your input pin.

For this to happen it means when there is no 5v signal at the input pin, it is considered to be on a 'LOW' state.

Most pins have a threshold voltage where they flip from 'HIGH' to 'LOW'. The atmega 328 chips arduino uses have a 3v threshold. Anything less than 3v is considered LOW and anything above is considered HIGH.

If your circuit has a few other features and voltage is passing through the chip and other parts of the circuit, a voltage could be induced or detected by your input pin involuntarily, causing a false positive scenario where it thinks you pushed the button when you didn't. This third state is called 'floating'.

For the sake of simplicity I'll use imaginary numbers for this next bit. Say you have a relay or coil that produces a magnetic field, the input pin which has nothing to do with the relay or coil might read 3.3v for a fraction of a second and then 0v or .6v then 1v and 0v again when this relay or coil energizes. If something occurs where the pin reads above 3v the pin state is HIGH.

To prevent the pin from reading HIGH until you trigger it with a 5v signal a pull down resistor is used. This resistor is called a 'pull-down' because it connects your input pin directly to ground. This let's your input pin read a constant 0v unless you specifically send it a 5v signal.

The same is similar with a pull up resistor but with opposite logic. It keeps a constant 5v signal to the input pin and will only allow the pin to read 0v when a user allows it.

/r/arduino Thread