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

How to Calculate PCB Trace Resistance

How to Calculate PCB Trace Resistance

A practical guide to calculating PCB trace resistance, covering the core formula, how geometry affects resistance, worked examples, and design tips to minimize voltage drop and heat.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 27, 2026
Why Your PCB Is Failing: Debugging Common Issues

Why Your PCB Is Failing: Debugging Common Issues

A practical guide to diagnosing and fixing PCB failures, covering common symptoms, a step-by-step debugging workflow, essential tools (multimeter, oscilloscope, logic analyzer, thermal camera), a pre-power-up checklist, and the design mistakes that most often lead to broken boards.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 27, 2026
PCB Impedance Control: A Practical Guide for Engineers

PCB Impedance Control: A Practical Guide for Engineers

A practical guide to PCB impedance control, covering why it matters for signal integrity, the four physical variables that shape trace impedance, and how to enforce impedance targets from stackup planning through routing and fabrication.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 27, 2026
EMI/EMC in PCB Design: How to Reduce Interference

EMI/EMC in PCB Design: How to Reduce Interference

A practical guide to reducing EMI in PCB design through grounding, return path control, shielding, and layout best practices. Covers EMC compliance with CISPR 32 and FCC Part 15.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 24, 2026
PCB Grounding Techniques for Noise Reduction and Stability

PCB Grounding Techniques for Noise Reduction and Stability

A practical guide to PCB grounding techniques — ground planes, return paths, star grounding, and analog/digital partitioning — with best practices for reducing noise and improving signal stability.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 24, 2026
How to Design a PCB Footprint (Step-by-Step Guide)

How to Design a PCB Footprint (Step-by-Step Guide)

A step-by-step guide to designing accurate PCB footprints — covering pads, silkscreen, courtyards, IPC-7351 density levels, origin setup, and common mistakes to avoid.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 24, 2026
PCB Stackup Design: How to Build the Right Layer Structure

PCB Stackup Design: How to Build the Right Layer Structure

A practical guide to designing multilayer PCB stackups for signal integrity, EMI control, and stable power delivery. Covers layer types, controlled impedance, common mistakes, and how modern tools simplify the process.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 24, 2026
How AI Is Changing PCB Design

How AI Is Changing PCB Design

A look at how AI is reshaping PCB design by automating routing, placement, and signal integrity checks so engineers can focus on architecture and higher-level decisions.

Profile avatar of Yaneev Hacohen
Yaneev Hacohen
|April 23, 2026