Raspberry Pi Electronics Calculator — LED, Voltage Divider, Color Code

Required Resistor
—

Why does an LED need a resistor?

The Problem

An LED has (almost) no internal resistance. Without a series resistor, an uncontrolled high current flows — the LED burns out within milliseconds and the Raspberry Pi’s GPIO pin can be permanently damaged.

The Solution: Ohm’s Law

In a series circuit, the total voltage is distributed across all components. The LED “consumes” its forward voltage Vf (1.8–3.5 V depending on the color). The rest goes to the series resistor — this determines the current according to Ohm’s Law.

The Formula

VR = Vcc − Vf  (Spannung am Widerstand)
R = VR ÷ If  (Ohmsches Gesetz: R = U / I)

R = (Vcc − Vf) ÷ If

Vcc — Supply voltage, e.g., 3.3 V on GPIO or 5 V on the power pin

Vf — Forward voltage of the LED (datasheet, depends on color)

If — Desired operating current, typically 10 mA = 0.01 A

R — Required resistance value in Ohms (Ω)

Notes for the Raspberry Pi

Mind the GPIO Current Limit

Each GPIO pin provides a maximum of 16 mA. 8–10 mA are recommended for continuous operation. Exceeding 16 mA can permanently damage the pin.

Blue and White LEDs on 3.3 V GPIO

Blue/white LEDs have Vf ≈ 3.0–3.5 V. With a 3.3 V GPIO, there’s barely any headroom — the LED will light up very dimly. Solution: 5 V pin + Transistor (e.g., BC547) as a switch.

E12 Standard Values

Resistors are not available in every value. The calculator shows the nearest E12 standard value — the standard series in any assortment box. Deviations of ±20% are normal and uncritical.

Required R2
—

What is a voltage divider and why do I need it?

The Problem: 5-V-Sensoren am 3,3-V-Pi

Many sensors and modules operate at 5 V and output 5 V signals. However, the Raspberry Pi’s GPIO pins can handle a maximum of 3.3 V — 5 V can permanently destroy the SOC.

The Solution: Voltage Divider

Two resistors connected in series (R1 and R2) divide the voltage proportionally. The reduced output voltage is present across the bottom resistor (R2).

Vout = Vin × R2 ÷ (R1 + R2)

Rearranged for R2:

R2 = Vout × R1 ÷ (Vin − Vout)

Important Limitations

Only Suitable for Signal Lines

A passive voltage divider is only suitable for signal lines with very low current (e.g., UART RX, GPIO input). Under load, the voltage drops.

Not for Bidirectional Buses (I2C, SPI)

For I2C and SPI, a bidirectional level shifter (module with BSS138, approx. 1–2 €) is recommended.

Recommended Values for 5 V → 3.3 V

Proven: R1 = 1 kΩ, R2 = 2 kΩ → Vout = 3.33 V ✓

Resistance Value
—

How does the resistor color code work?

History

The color code was developed in the 1920s because it was nearly impossible to print small numbers on tiny components. To this day, it is the standard on almost every through-hole resistor.

4-Band Resistor (Standard)

Band 1 + 2: First and second digit of the value  |  Band 3: Multiplier  |  Band 4: Tolerance

5-Band Resistor (Präzision)

Band 1 + 2 + 3: Three digits  |  Band 4: Multiplier  |  Band 5: Tolerance

Holding the Resistor Correctly

The tolerance band (Gold/Silver) is always at the edge — read from the other side.

Mnemonic for digits 0–9:

“Bad Boys Run Our Young Girls Behind Victory Garden Walls”

Black = 0 Brown = 1 Red = 2 Orange = 3 Yellow = 4 Green = 5 Blue = 6 Violet = 7 Gray = 8 White = 9

Understanding Tolerance

A 1 kΩ resistor with ±5% (Gold) can range between 950 Ω and 1050 Ω — perfectly sufficient for all normal Pi circuits.

Remembering the Multiplier

Same colors as digits, just as a power of ten: Brown = ×10, Red = ×100, Orange = ×1,000, etc. Gold = ×0.1, Silver = ×0.01.