Skip to content
Electronics Basics

LED

12 min read · Beginner

LEDs Explained: Polarity, Current Limiting, Wiring, and Troubleshooting

A light-emitting diode (LED) is a semiconductor device that emits light when current flows through it in the forward direction. LEDs are used as status indicators, displays, lighting sources, optical transmitters, and part of sensors. They are efficient and long-lasting when driven within their electrical and thermal limits, but they are not simply small lamps that can be connected directly to any voltage source.

An LED has an anode and a cathode. In normal operation, the anode is at a higher voltage than the cathode, and the current must be limited by a resistor, constant-current driver, or another circuit designed for the LED. The LED's forward voltage depends on semiconductor material, color, current, temperature, and construction. A red indicator LED may have a forward voltage around 1.8–2.2 V at a modest current, while blue and white LEDs often require a higher voltage. These are approximate ranges, not design guarantees.

The main practical rule is to design for current, not merely voltage. LEDs have a nonlinear current-voltage curve, so a small increase in voltage can cause a large increase in current. Too much current can damage the LED or the microcontroller pin driving it. High-power LEDs also need thermal management.

This guide covers polarity, resistor calculations, Arduino and ESP32 GPIO use, series and parallel arrangements, brightness control, measurement, and troubleshooting. The examples use low-voltage circuits; always verify the exact LED and board specifications before wiring.

1. Identify the anode and cathode

The anode is the positive-side terminal in ordinary forward operation; the cathode is the negative-side terminal. On a new through-hole LED, the longer lead is often the anode, and the shorter lead often indicates the cathode. Many LEDs also have a flat edge on the body near the cathode. These are helpful clues, but they are not dependable if the leads have been trimmed or the package differs. Confirm polarity from the part's datasheet or a diode-test measurement.

In a schematic, the LED symbol resembles a diode symbol with two arrows pointing outward to represent emitted light. The bar marks the cathode. On a breadboard, each LED lead must be connected to the intended node; placing both leads in the same connected row can short the LED out of the circuit.

An LED is a diode, so reverse bias normally blocks current, but it does not tolerate unlimited reverse voltage. Some LEDs have a low reverse-voltage rating. If the circuit can apply reverse voltage or AC, use a suitable protection arrangement specified by the manufacturer, such as a reverse-parallel protection diode or a correctly designed driver. Do not assume an LED is safe simply because it does not light.

Before powering the circuit, trace the path from supply through the current-limiting element, LED, and return. Verify the direction and the voltage at every relevant point. A quick sketch often prevents a common beginner mistake: wiring the LED backwards and then increasing supply voltage in an attempt to make it illuminate.

2. Why an LED needs current limiting

An LED's forward voltage is not a precise current regulator. Once the junction is conducting, current can increase sharply with a small rise in voltage. If a low-impedance source is connected directly across the LED, the current may exceed its safe rating. A series resistor limits the current by dropping the remaining supply voltage.

For a simple circuit, estimate the resistor with R = (V_supply − V_F)/I_LED. Here, V_supply is the source voltage, V_F is the LED forward voltage at the intended current, and I_LED is the target current. Check the LED datasheet and choose a standard resistor value that keeps the worst-case current within limits.

Example: a red LED has an estimated forward voltage of 2.0 V, the supply is 5 V, and the target current is 8 mA. R = (5 − 2)/0.008 = 375 Ω. A 390 Ω resistor gives approximately 7.7 mA under the assumed conditions. Because the LED's actual forward voltage and supply voltage vary, treat this as an estimate and confirm it against the component ratings.

Calculate resistor power as P = I²R or P = (V_supply − V_F) × I. In this example, the resistor dissipates about 0.023 W, so a suitable standard resistor with adequate margin is generally enough. At higher voltages or currents, power and resistor voltage ratings become more important.

A resistor is not always the best choice. High-power LEDs, battery systems with changing voltage, and precision brightness control may need a constant-current driver. Use the approach specified by the LED manufacturer.

3. Wiring an LED to Arduino or ESP32

For a simple indicator, connect a microcontroller GPIO pin through a series resistor to the LED anode, and connect the cathode to the board's ground. The exact polarity can be reversed in software-controlled sinking arrangements, but the current path and pin mode must be understood. Do not connect the LED directly to a GPIO pin without current limiting.

A typical Arduino Uno uses 5 V logic, while common ESP32 boards use 3.3 V logic and their GPIOs are generally not 5 V tolerant. The resistor value must be recalculated for the board's actual output voltage and the LED's forward voltage. Check the board documentation for recommended GPIO current, absolute maximum ratings, and total current limits; absolute maximum values are not targets for normal operation.

Example for a 3.3 V output and a red LED estimated at 2.0 V with a 5 mA target: R = (3.3 − 2.0)/0.005 = 260 Ω. A nearby standard value such as 270 Ω gives about 4.8 mA under those assumptions. If the LED forward voltage is close to the supply voltage, the available voltage across the resistor may be too small for reliable current control.

On a breadboard, make sure the LED's leads are in separate electrical rows and that the resistor is in series rather than parallel with the LED. Connect the board ground and circuit ground correctly. For an external LED or longer wire, consider signal integrity and avoid running GPIO wires alongside noisy motor power wiring.

Never use a microcontroller pin to power a motor, high-power LED, LED strip, or other substantial load. Use an appropriate transistor or driver, and a separate supply if required.

4. Series and parallel LED arrangements

When LEDs are connected in series, the same current flows through every LED. The supply voltage must exceed the sum of their forward voltages plus the voltage needed by the current-limiting resistor or driver. The resistor calculation becomes R = (V_supply − ΣV_F)/I. If the supply voltage is too low, the LEDs may not reach the intended current. If the supply varies, the current may vary unless a suitable driver is used.

For example, two red LEDs with approximate forward voltages of 2.0 V each connected to a 9 V supply at a target current of 10 mA leave about 5 V across the resistor. The estimated resistor is 5/0.01 = 500 Ω, so a nearby standard value such as 510 Ω gives about 9.8 mA under the assumptions. Check the resistor power and the LED ratings.

Parallel LEDs each experience the branch voltage, but small forward-voltage differences can cause uneven current sharing. One LED may draw more current, heat up, and take an even larger share. For simple indicator circuits, use an individual series resistor for each LED branch or a driver designed for the parallel arrangement. Do not assume a single resistor shared by several parallel LEDs will provide equal brightness or reliable current sharing.

For LED strips and high-power lighting, follow the manufacturer's supply and driver requirements. Strips may contain built-in resistors or current regulators, while bare LED modules may not. Verify the exact product rather than assuming every strip marked “12 V” has the same internal arrangement.

Series and parallel wiring must also respect connector, PCB trace, and power-supply limits. Add the current demands of all branches and consider startup behavior and thermal conditions.

5. Brightness control with PWM

Pulse-width modulation (PWM) controls average delivered power by switching a digital output rapidly between low and high states. Duty cycle is the fraction of each cycle spent high. A 25% duty cycle means the output is high for one quarter of the cycle. At a suitable frequency, the eye perceives the LED as dimmer rather than seeing each individual pulse, although cameras may capture flicker or banding.

PWM does not remove the need for current limiting. During each high pulse, current must remain within the LED and driver ratings. A resistor or constant-current driver is still required. For a simple LED, PWM is often used to adjust perceived brightness; the exact relationship between duty cycle and perceived brightness is not linear because human vision is nonlinear.

Microcontroller PWM frequency and resolution vary by platform and software library. Choose settings appropriate to the application, and consider flicker, camera artifacts, audible effects in some drivers, and switching losses. Some GPIO pins have special boot or peripheral functions, so check the board's pin documentation before selecting a pin.

For a high-power LED, do not switch the load directly from a GPIO. Use a transistor or MOSFET driver with adequate current and voltage ratings, appropriate gate drive, thermal design, and supply decoupling. Ensure the controller and driver share a suitable signal reference where the circuit requires it. If the LED supply is electrically isolated, preserve that isolation and use the specified interface.

For a simple indicator, begin with a modest current and confirm the LED and resistor remain cool. Increase brightness only within the ratings; visual brightness alone is not a reliable indicator of safe current.

6. LED polarity and protection in unusual circuits

Most indicator LEDs are designed for DC forward current. If a circuit exposes the LED to reverse voltage, an AC signal, or inductive transients, check the reverse-voltage rating and protection requirements. A protection diode connected antiparallel can limit reverse voltage across an LED in some low-voltage applications, but its suitability depends on the circuit and signal. Do not add protection components without considering their effect on the circuit.

A series resistor protects against excess forward current but does not necessarily protect against a large reverse voltage. Likewise, a resistor that is suitable at 5 V may dissipate too much power if the supply is accidentally replaced with 12 V. Verify both current and resistor power for the highest possible supply voltage and lowest expected LED forward voltage.

For an indicator driven from a microcontroller pin, check whether the pin is configured to source current or sink current. If the LED is connected from a supply to a pin, driving the pin low may turn it on, while driving it high may turn it off. This arrangement can be valid within the board's limits, but a supply above the GPIO's permitted voltage must not be connected to the pin.

Some development boards include a built-in LED connected to a specific pin, sometimes through a resistor. Board revisions and pin mappings vary. Use the board documentation rather than assuming the built-in LED is always on the same GPIO. If a built-in LED does not respond, check the pin definition, board selection, polarity, and software before changing the external wiring.

7. Testing an LED and measuring its current

A multimeter with diode-test mode can often identify LED polarity and show a forward-voltage reading. With the LED disconnected from power, place the red probe on the anode and black on the cathode. Some meters may light red or amber LEDs faintly. Blue or white LEDs may require more test voltage than the meter provides, so no light does not prove the LED is faulty.

To measure operating current, use a meter in series with the LED branch and the correct current input. Power down before changing connections. Never connect a meter set to current mode directly across a supply, because the meter's low-resistance current path can create a short circuit. For a simple LED circuit, measuring voltage across the series resistor and calculating I = V/R can be a convenient alternative.

Measure the supply voltage and voltage across the resistor while the LED is on. The resistor drop divided by its measured resistance gives the approximate current. This also helps diagnose why brightness differs from expectation. Keep the measurement setup within the meter's and circuit's ratings.

If an LED has failed, inspect for excessive current, reversed polarity, overheating, ESD damage, or a supply transient. An LED that is visibly cracked or discolored should be replaced with a part whose current, forward voltage, wavelength/color, viewing angle, and package suit the design. If the LED failed repeatedly, investigate the driver and supply rather than repeatedly fitting a new one.

8. Common LED problems

LED does not light: Check the power source, polarity, series resistor, breadboard connections, GPIO pin mapping, and software state. Measure the voltage across the resistor and LED. If the resistor has nearly the full supply voltage across it, the LED may be open or reversed; interpret the measurement in the context of the circuit.

LED is too dim: The current may be lower than expected because the resistor is too large, the supply voltage is lower, or the GPIO cannot source the intended current. The LED itself may have lower luminous intensity or a different viewing angle. Do not solve dimness by removing the resistor; calculate the safe current and use an appropriate driver if more light is required.

LED burns out: Check for a missing or incorrect resistor, excessive supply voltage, reversed transients, or current-driver failure. Verify the maximum continuous and pulse current ratings and thermal conditions.

Microcontroller resets when LED turns on: A single low-current indicator should not normally cause a reset on a correctly powered board, but a high-power LED or many LEDs can overload the supply or ground path. Measure voltage during switching and use a suitable driver and supply.

Multiple parallel LEDs have unequal brightness: Branch currents may not be sharing equally because forward voltages differ. Use individual resistors or a driver designed for the array.

LED flickers or looks uneven on camera: PWM frequency, duty-cycle updates, power supply ripple, or loose connections may be responsible. Test at a stable brightness and check the actual current and supply behavior.

9. Selecting LEDs and drivers

Choose an LED based on forward current, forward voltage, luminous intensity or flux, color or wavelength, viewing angle, package, thermal resistance, and environmental rating. For infrared or ultraviolet LEDs, wavelength and optical safety may be especially important. For indicator use, a lower current can often provide enough brightness while reducing power consumption.

The datasheet may specify absolute maximum current and a recommended operating current. Do not treat the absolute maximum as the normal design target. Check pulse-current ratings only when the pulse duration, duty cycle, and thermal conditions meet the datasheet conditions. Pulsed operation does not automatically permit any arbitrary peak current.

For high-power LEDs, the driver must regulate current and handle heat. The LED's junction temperature affects efficiency, forward voltage, and lifetime. A heatsink and proper thermal interface may be necessary. Thermal design should use the manufacturer's thermal resistance values and the actual ambient temperature, not just whether the metal body feels warm.

Select a transistor or MOSFET driver with adequate current and voltage ratings, low enough conduction loss, appropriate switching behavior, and a suitable gate/base drive. Include protection for inductive loads where required and ensure the power supply can deliver the load current. A logic-level MOSFET must be evaluated at the actual gate voltage, not only by its threshold-voltage number.

For LED strips, modules, and lamps, follow the manufacturer's specified input voltage and connection polarity. Do not assume that a product's advertised wattage tells the full story about current peaks, thermal limits, or dimming compatibility.

10. FAQs and practical checklist

Can I connect an LED directly to 5 V? Usually not. Unless the module includes current limiting, use a suitable resistor or driver.

Does a higher resistor make the LED brighter? No. In a simple series circuit, a higher resistor generally reduces current and makes the LED dimmer.

Can I use the same resistor for a red and a blue LED? Not without checking the supply, forward voltages, and target current. Different forward voltages change the current through a given resistor.

Can a GPIO power a 1 W LED? Do not assume so. A 1 W LED can require substantial current and thermal management. Use a suitable driver and supply.

Why is my LED dim on an ESP32 compared with an Uno? The ESP32's GPIO high level is typically 3.3 V while the Uno uses 5 V logic. The lower voltage changes the resistor headroom and current. Board pin limits and LED characteristics also matter.

Checklist before powering an LED

  • Identify anode and cathode.
  • Calculate the resistor or select a current driver.
  • Check GPIO, LED, resistor, and supply ratings.
  • Verify wiring and ground reference.
  • Test at low current before increasing brightness.
  • Investigate repeat failures rather than bypassing current limiting.

LEDs are easy to use when their current and thermal needs are understood. A correctly chosen resistor or driver, verified polarity, and sound wiring will make a project brighter in the right way: reliably, predictably, and within the component ratings.