ROBOTICS 101Concept explainer

Voltage Dividers and Pull-up Resistors

Two resistors in a row split a voltage, which is how many simple sensors turn a change in resistance into a voltage a microcontroller can read. A single resistor to the supply, called a pull-up, gives an input pin a definite level when nothing else drives it.

The voltage divider

With supply \(V_{\text{in}}\), a fixed resistor \(R_1\) on top and a sensor \(R_2\) on the bottom, the middle point sits at

$$V_{\text{out}} = V_{\text{in}}\,\frac{R_2}{R_1 + R_2}$$

A light-dependent resistor drops from about 100 kΩ in the dark to about 1 kΩ in bright light, so \(V_{\text{out}}\) falls as light rises. Choosing \(R_1\) near the sensor's middle value gives the widest swing.

Pull-up and pull-down resistors

A button connects a pin to ground only while pressed. When released, the pin is connected to nothing. With no resistor, it floats and picks up electrical noise, so the reading flickers. A pull-up resistor ties the pin weakly to 3.3 V, so it reads 1 when released and 0 when pressed.

What to notice

Choose "None (floating)" and watch the logic value change on its own, even with no one touching the button. Many microcontrollers have built-in pull-up resistors you can turn on in code, which is the usual fix.