September 5, 2023

Understanding Pull-up and Pull-down Resistors: A Guide for Arduino and Microcontrollers

A simplified schematic diagram illustrates how pull-up and pull-down resistors are utilized in microcontroller applications

Pull-up and pull-down resistors are vital components in the world of electronics, especially in microcontroller-based circuits. Whether you're using an Arduino, Raspberry Pi, or any other microcontroller, understanding pull-up and pull-down resistors is essential. In this blog, we'll dive deep into these components, how they work, and why they are crucial for reliable circuit performance.

What are Pull-ups and Pull-downs?

Pull-up and pull-down resistors are components added to circuits to ensure that pins on a microcontroller have a known voltage level, usually either VCC (5V or 3V) or GND (0V), before they are actively driven by other components. Pull-ups pull the voltage level up to VCC when the pin is not active, while pull-downs pull the voltage down to 0V.

Pull-up Resistor vs Pull-down Resistor

To more clearly highlight the distinctions between pull-up and pull-down resistors, I'll present a side-by-side comparison in the table below:

Pull-up Resistors Pull-down Resistors
Connect between I/O pin and +supply voltage, with an open switch connected between I/O and ground. Connect between an I/O pin and ground, with an open switch connected between I/O and +Supply.
Keeps the input “High” Keeps the input “Low”
More commonly used Less commonly used

What is PinMode and DigitalRead in Arduino?

In Arduino, setting the pinMode for a GPIO (General Purpose Input/Output) pin as INPUT sets the microcontroller to read incoming signals. If digitalRead reads a high voltage close to 5V, it will return HIGH, and if it reads close to 0V, it returns LOW. However, when a pin is set as an INPUT and is not connected to any voltage or is between different voltage levels, it is said to be "floating," and its state could be unreliable.

Importance of Pull-up and Pull-down Resistors in Circuits

To prevent a pin from floating, we use either a pull-up or a pull-down resistor. The resistance usually ranges around 1K to 10K ohms, although the exact value can be calculated based on the impedance requirements of the circuit.

When connected in a circuit, the resistor pulls the voltage across the pin to a known level. For example, with a pull-up resistor, a digitalRead on an Arduino GPIO pin will return HIGH unless actively driven low. This ensures a stable logic level, thus making the reading consistent and reliable.

Schematics and Practical Examples

In a typical pull-up schematic, the resistor is connected between the pin and VCC. For pull-downs, the resistor connects the pin to GND. These schematics often appear in circuits with switches, NAND gates, CMOS, and TTL logic devices.

A typical schematic diagram of pull-up resistor and pull-down resistors used in ESP32 microcontroller
Typical pull-up resistor and pull-down resistors used in ESP32 microcontroller.

Role in Digital Protocols and Transistors

Pull-up and pull-down resistors also have their place in digital protocols like I2C, where they are used to maintain data line and clock line states. They also find applications in circuits with transistors, acting as a voltage divider when the transistor is in the ON or OFF state.

Arduino's Built-In Pull-ups and Pull-downs

Since pull-up resistors are so commonly needed, many MCUs, like the ATmega328 microcontroller on the arduino microcontrollers often have internal pull-up and sometimes pull-down resistors that can be enabled or disabled through software by setting pinMode to INPUT_PULLUP or INPUT_PULLDOWN. This is extremely useful when you're low on external components.

To enable internal pull-ups on an Arduino, you can use the following line of code in your setup() function:

pinMode(5, INPUT_PULLUP); // Enable internal pull-up resistor on pin 5
pinMode(6, INPUT_PULLUP); // Enable internal pull-up resistor on pin 6
pinMode(7, INPUT_PULLUP); // Enable internal pull-up resistor on pin 7

How to Calculate Resistance of a Pull-up Resistor?

The value of the resistor in ohms is essential for maintaining the impedance balance in the circuit. A value too low will cause excessive current to flow through the circuit, while a too high resistance may not effectively pull the voltage level to 0V or 5V.

Let's say you want to limit the current to approximately 1mA when the button is pressed in the circuit above, where Vcc = 5V. What resistor value should you use?

To calculate the pull-up resistor, we'll be using Ohm's Law:

Where is the Vcc, is the current through the pull-up resistor, and is the resistance of the pull-up resistor.

Rearrange the above equation with little algebra to solve for the resistor:

Pull-ups vs. Pull-downs: When to Use Which?

Choosing between pull-ups and pull-downs often depends on the specific requirements of your circuit. However, pull-ups are generally more common because CMOS and TTL logic chips usually have a higher noise margin at the high-end (closer to VCC than to GND).

The Physics Behind It: Ohm's Law

Ohm's Law is the foundation when it comes to understanding resistors. The formula , where is the voltage, is the current, and is the resistance, governs how resistors work in circuits. The resistor limits the current that can flow between VCC and the input pin, balancing the impedance and providing a stable voltage level for digitalRead to interpret.

Real-world Applications: Switches and Sensors

In real-world applications, pull-up and pull-down resistors are commonly used with switches and sensors. When a switch is open, a pull-up resistor will ensure that the voltage at the pin is pulled up to VCC (5V or 3V). When the switch is closed, it connects the pin directly to GND, overriding the pull-up and bringing the voltage to 0V.

In sensor applications, a pull-up or pull-down can help stabilize the voltage level read by the microcontroller, offering a more accurate and reliable reading. For example, a pull-up can ensure that a temperature sensor starts with a known "high" state before it sends its own signal.

Voltage Dividers and Level Shifters

In some cases, pull-up or pull-down resistors are part of a voltage divider circuit, especially when you're interfacing 5V and 3V components. A voltage divider consists of two resistors in series connected across a voltage supply. The output voltage can be tapped between the two resistors, providing a reduced voltage that is proportional to the ratio of the resistors.

Common Pitfalls and Tips

  1. Wrong Resistor Value: Choosing a resistor with a value too low can cause excessive current to flow, wasting power and possibly damaging the microcontroller pin.
  2. Forget to Connect the Resistor: When the resistor is not connected, the pin will float, leading to unreliable readings.
  3. High-impedance Sources: If you're connecting a high-impedance source to a pin, even a large pull-up or pull-down resistor may not effectively set the logic level. In this case, consider using a buffer or amplifier circuit.
  4. Wire Length: Longer wire runs can introduce noise and resistance, affecting the performance of pull-up and pull-down resistors.

Final Thoughts

Pull-up and pull-down resistors are more than just "additional components" in your electronic projects; they're fundamental to the reliable operation of microcontrollers, transistors, and logic gates. Understanding their function, role in circuits, and practical applications can make the difference between a project that functions inconsistently and one that operates reliably.

By now, you should have a solid understanding of pull-up and pull-down resistors, how to set the pinMode and use digitalRead in your Arduino projects, and the significance of resistance and impedance in these configurations. Whether you're a hobbyist or a professional, these resistors are tools you'll come back to time and time again.

With this, we've reached the end of our comprehensive guide. Happy building!

Profile avatar of the blog author

Jharwin Barrozo

Jharwin is an electronics engineer mainly focused on satellites. He built his own ground station using Flux to monitor RF activities on the International Space Station. Find him on Flux @jharwinbarrozo

Go 10x faster from idea to PCB
Work with Flux like an engineering intern—automating the grunt work, learning your standards, explaining its decisions, and checking in for feedback at key moments.
Illustration of sub-layout. Several groups of parts and traces hover above a layout.
Design PCBs with AI
Introducing a new way to work: Give Flux a job and it plans, explains, and executes workflows inside a full browser-based eCAD you can edit anytime.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Design PCBs with AI
Introducing a new way to work: Give Flux a job and it plans, explains, and executes workflows inside a full browser-based eCAD you can edit anytime.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Design PCBs with AI
Introducing a new way to work: Give Flux a job and it plans, explains, and executes workflows inside a full browser-based eCAD you can edit anytime.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.

Related Content

Designing PCBs for IoT Devices: Key Considerations

Designing PCBs for IoT Devices: Key Considerations

A practical guide to designing PCBs for IoT devices, covering low-power layout, wireless and RF considerations, and best practices for embedded hardware.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|June 2, 2026
PCB Design Constraints: What Engineers Need to Know

PCB Design Constraints: What Engineers Need to Know

An overview of the electrical, mechanical, and manufacturing constraints that shape PCB design, with the rules and guidelines engineers need to follow.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|June 2, 2026
Panelization in PCB Manufacturing: Methods and Best Practices

Panelization in PCB Manufacturing: Methods and Best Practices

A practical guide to PCB panelization methods like V-scoring and tab routing, with best practices to improve manufacturing efficiency and reduce production costs.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|June 2, 2026
SMT vs Through-Hole Technology: Which Should You Use?

SMT vs Through-Hole Technology: Which Should You Use?

A beginner-friendly comparison of SMT and through-hole PCB assembly, covering their differences, trade-offs, and when to use each method.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|June 2, 2026
Analog vs Digital PCB Design: Key Differences Explained

Analog vs Digital PCB Design: Key Differences Explained

Learn the key differences between analog and digital PCB design and how to manage mixed-signal layouts for better signal integrity.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|May 15, 2026
Decoupling Capacitors in PCB Design: Placement and Selection

Decoupling Capacitors in PCB Design: Placement and Selection

Learn how to place and select decoupling capacitors to improve power integrity in PCB design.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|May 15, 2026
Differential Pair Routing: Rules and Best Practices

Differential Pair Routing: Rules and Best Practices

Learn the core rules of differential pair routing including parallel routing, consistent spacing, length matching, and return path management for high-speed PCB designs.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|May 15, 2026
PCB EMI Problems: Causes and Solutions

PCB EMI Problems: Causes and Solutions

Learn the most common causes of PCB EMI issues and proven layout, grounding, shielding, and filtering techniques to pass EMC compliance.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|May 15, 2026