why sometimes you need a pull down resistor, sometimes you don't

Hello,
I've seen inputs going into an input pin both ways.

http://s15.postimg.org/69hibyrgr/differencebetween.png

Sometimes the tutorial recommends a pull down resistor, sometimes not. How do they decide? I see this with PIR sensors. The adafruit uses a pull down resistor, but plenty of other ones don't.

Inputs on micro controllers can float if they are open. A pull down resistor biases the pin to ground so when your switched 5V is open, the pin sees ground, when the switch is closed, the pin sees 5V. There is no in between.

To answer your question, sometimes it works without a pull down resistor, but it is best practice to use one.

Another common practice is to use the internal pull up resistor on the microcontroller and instead of switching 5V, you switch to ground.

sometimes it works without a pull down resistor,

No it doesn't.

You always need a resistor or a change over switch. Some times people use the internal resistor. See this for the lowdown:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

However, if the output of the device is a logic signal then there is no need for a resistor because the logic signal provides a solid zero and one.

Remember nothing connected to an input is not the same as a logic zero.

Sometimes the peripheral circuit has its own pullup resistor installed. In that case, you don't need one on the main board.

But the circuit you posted doesn't have a separate circuit board. So the top circuit probably enables the internal pullup resistors in the microprocessor, in the program. They are both pull up circuits, not pull down.

Grumpy_Mike:
However, if the output of the device is a logic signal then there is no need for a resistor because the logic signal provides a solid zero and one.

So, sometimes it works without one...

dustin02rsx:
So, sometimes it works without one...

Not for a switch.