An LED can be dimmed by quickly turning it on and off, several times a second. By varying the mark space ratio, the brightness is varied.
A simple implementation of a PWM system would be a clock feeding an LED and protective resistor to the ground.
The clock should ideally oscillate at a frequency of 50Hz to ensure that you will not see the oscillation. To test this, you can either use a signal generator to provide a square wave, as below, or create a circuit to do it for you.
Step 1: Relaxation Oscillator
The capacitor C1 charges and discharges through the resistor R1, and the time taken for this cycle to occur is the period of the waveform.
Step 2: Relaxation Oscillator
For the purposes of general PWM of LEDs, there is no need for absolute precision with the frequency. If there is a requirement for precision, then the potentiometer chosen should be as close to, but no more than 2R1, and a compensation resistor equal to R1-RP/2.
An alternate solution is to use two resistors in series with the two diodes, to give a fixed, and pre-defined duty cycle.