Notifications
Clear all

Pull-Up and Pull-Down Resistors in Arduino

5 Posts
3 Users
2 Reactions
3,273 Views
1
Topic starter

Hi everyone,

I'm trying to understand the purpose and usage of pull-up and pull-down resistors in Arduino circuits. I’ve seen these terms mentioned in various tutorials, but I’m still unclear on when and why to use them. Could someone explain what these resistors are, how they function with Arduino inputs, and when it’s appropriate to use a pull-up resistor versus a pull-down resistor?

Thank you!


1 Answer
1

Imagine you have a button connected to your Arduino. You want the Arduino to know when the button is pressed or not. Without a pull-up or pull-down resistor, when the button is not pressed, the input pin might randomly read HIGH or LOW because it’s floating—picking up noise from the environment. This makes it hard for the Arduino to know if the button is actually pressed or not.

What Does "Pull-Up" and "Pull-Down" Mean?
Pull-Up Resistor: It "pulls" the input pin to a HIGH state(like ON). To use it, simply connect a big value resistor(say 10K ohm) in series with the pin to +5V. This will force the pin to be at +5V by default.

Pull-Down Resistor: It "pulls" the input pin to a LOW state (like OFF). To use it, simply connect a big-value resistor(say 10K ohm) in series with the pin to GND. This will force the pin to be at 0V by default.

When should you use each?

Img source**

Use a Pull-up resistor when:

You want the input to be HIGH (like ON) when the button or switch is not pressed.

Note: There is a built-in pull-up resistor for every digital pin on Arduino. To enable it, this command is used:

pinMode(digital pin,INPUT_PULLUP)

Use a Pull-down resistor when:

You want the input to be LOW (like OFF) when the button or switch is not pressed.
You need to add an external resistor, as Arduino does not have built-in pull-down resistors.

 


Neeraj Dev Topic starter 09/11/2024 4:14 am

@ankunegi I get it. But can’t I just connect the input pin directly to 5V or GND without a resistor? What will happen then?


Yvette 09/11/2024 5:05 am

You are forgetting the whole point of the pull resistors: they ensure that the pin remains in a stable state(either 5V or Ground) until an opposite voltage state is given to it so that the pin can detect this state change and the system can perform some action. If you will connect it to 5V directly, it will never be able to detect the GND because then it will be connected to two different voltage state at the same time causing a short circuit. The high-value pull-up or pull-down resistor ensures this does not happen.


Neeraj Dev Topic starter 10/11/2024 6:31 am

Thanks for the explanation, I got it now. And how do I choose the right resistor value for pull-up or pull-down resistors? Also, should I use an internal pull-up for my button or use an external resistor, which is better?


Share: