A digital pin only outputs two voltages: 0 V or 5 V. But your LED can be dim, medium, or bright. How? The pin switches between the two voltages so fast that the LED's effective average voltage lands somewhere between them. That's pulse-width modulation: same frequency, varying ratio of "on" to "off."

Duty cycle is just average voltage

On the Uno, analogWrite(pin, value) takes a value from 0 to 255. 128 means 50% duty — pin is HIGH half the time, LOW the other half. The average is 2.5 V. 64 means 25%. 192 means 75%. The PWM frequency on most Uno pins is about 490 Hz — well above what the eye can resolve as flicker.

An LED, a motor, a heater, anything that responds to average power, treats PWM as if it were analog. A capacitor and resistor (an RC filter) can make it truly analog if you need real DC — but for an LED, your eye does the filtering for free.

Linear input, perceptual curve

Here's the gotcha: human brightness perception is logarithmic, not linear. A ramp from 0 to 255 doesn't look like a smooth fade — it looks like the LED jumps to "mostly bright" by 50 and then slowly maxes out. For a perceptually-smooth ramp, square the input: analogWrite(pin, (i*i)/255);. Hardware is linear; eyes are not.