Pull-down

Hello, I recently learnt that a pull-down resistor with value of 10k Ohms is used to drain all unwanted voltage. Now the question:
Is it necessary for the resistor to be 10k ohms or it can be different or it varies from something? Probably from the Ohms law, but I dont know, its pull-down

Varies.

Lower resistance means more power is consumed with the line is pulled-up.

Lower resistance means the time constant is less (takes less time for the line to be pulled-down).

Lower resistance provides some immunity from noise.

This is a good discussion of resistance versus time constant for I2C…

The job of a pull-down or pull-up resistor is to be at least an order-of-magnitude larger than the
active device or switch it is connected too, and to not waste too much power - for low power
circuits higher values are used (at the risk of less noise-immunity).

Generally for use on a circuit board 100k to 10k will work, for signals going off-board 1k to 10k is
a better range (rejects noise and interference more).

Hello, I recently learnt that a pull-down resistor with value of 10k Ohms is used to drain all unwanted voltage.

Actually, the pull-down or pull-up is there to prevent a "floating" undefined input.

With nothing connected to an Arduino input, the input will float, it's undefined, and it might read high or low. (It's also very high impedance which means it can pick-up noise capacitively or electromagnetically with no actual electrical connection, and it might alternate between high and low.)

Let's look at the [u]Digital Read Serial Example[/u] -

When the switch is closed (on) Pin A0 is connected directly to +5V. (The pull-down is "overpowered" and with 5V across the pull-down resistor, and current flows through the resistor.) We can remove the pull-down and nothing will change... A0 will continue to read high.

When the switch is off (open) the resistor pulls-down the input* and prevents the input from floating high, insuring that A0 will read low.

If we remove the resistor, the input there is no connection to A0 (when the switch is off), the input will float and (with the switch off) A0 may read high or low. That's not very useful if it reads high with the switch off...

If we connect an output from one Arduino to the input of another, you don't need a pull-up or pull-down because the connected output pin drives the input high or low and it never floats.

Or, you could use a double-throw switch so the input is either connected to +5V (high) and ground (low) so it never floats.

Pull-up resistors are a lot more common than pull-downs, and the Arduino has built-in pull-ups that can be optionally enabled. Of course, with a pull-up the switch has to be wired to ground instead of +5V, and you may need to adjust the logic in your software.

  • We have something like a voltage divider where the pull-down resistor has a very-low resistance compared to the Arduino input. The lower resistance means all of the voltage is dropped across the Arduino input, with essentially no voltage dropped across the pull-down. That means both ends of the resistor are essentially ground, there is no voltage across the resistor and no current flows through it.

I tested the Button example (which says 10k ohm) with 1k, 10k, 100k and 1M and all they worked... that is kinda cofusing... I expected the 1M not to work...

JMD1:
… I expected the 1M not to work…

Why?
As mentioned by others, 1M will provide less noise immunity than lower values, but still holds the pin low until it is taken high by a button press.
The values suggested by MarkT in reply #2 are a good guide.

JMD1:
that is kinda cofusing... I expected the 1M not to work...

Write a sketch that measures the recovery time (how long it takes to go from HIGH to LOW).

Compare the recovery time for different resistances.

Thats true, the recovery time is getting bigger as the resistance is increasing

You now understand the essence of measuring capacitance using the time constant of an RC circuit.

And what affect lower / higher resistance has when working with pulldown / pullup resistors.