Pulse Width Modulated LED Torch




Pulse width modulation (PWM) can be used to vary the power, speed or brightness of many devices. With LEDs, PWM can be used to dim them, or make them brighter. I will use them make a small hand torch.

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

This circuit will produce a square wave with a duty cycle of 50%. Two 10K resistors connected to the +input of the op-amp provide a reference voltage, and R1 and C1, connected to the -input, create a time constant which controls the frequency, f = 1/{2ln(3)RC}.

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

By defining the frequency in step 1, R1 can be replaced with a potentiometer, RP, with a value of 2R1, and two diodes. This alteration will allow the duty cycle to vary, whilst maintaining a constant frequency.

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.

Step 3: Relaxation Oscillator Output

The clock signal can either be connected directly to a single LED, but this will not allow the LED to be controlled by an external logic source. It can instead be easier to feed this output to the base of a transistor, and then use the transistor to switch the LED on and off.

The potential divider on the input of the transistor is to reduce the output of the relaxation oscillator, since in it's off state, it will still output 2v. This needs to be reduced to below 0.7v in order to not to switch on the transistor, otherwise the LED will remain on constantly and cook.

Step 4: Increasing the Brightness

The other useful application of PWM with an LED is that the LED can have a larger than normal current passed through it making it brighter. Normally this current would destroy the LED, but since the LED is only on for a fraction of the time, the average power put through the LED is within tolerance.

The limit of this current is defined on the manufacturer's data sheet for the LED, identified as the forward pulse current. There are also often details regarding the minimum pulse width and duty cycles. Using a white LED as an example, the following specifications are given as:

Forward Current = 30mA
Pulse Forward Current = 150mA
Pulse Width =< 10ms
Duty Cycle =< 1:10

Using the pulse width and duty cycle information, the relaxation oscillator can be recalculated with T=2ln(2)RC

Assuming a 10nF capacitor is used, and wanting TON = 10ms, and TOFF = 1ms, the following calculations can be made, and then the circuit diagram drawn.

Step 5: Power Increase

The other requirement to increase the brightness is to increase the current flowing through the LED. This is relatively straight forward. Assuming a 5v logic supply to the LED, and from the data sheet the standard voltage of the LED is 3.6v. The protection resistor can be calculated by subtracting the LED voltage from the supply voltage, and then dividing this by the current.

R = (VS - VLED) / (iMAX)
R = (5 - 3.6) / 0.15
R = 1.4 / 0.15
R = 9.3 = 10R

It is however likely that the LED supply source may not be able to provide a sufficient current of 100mA, even if it is for a very short time. It may be necessary to power the LED through the transistor, possibly controlled by another transistor in series also capable of carrying the current.

In this circuit, the supply voltage of the op-amp should be used, as the 5v logic supply will be too small. There is a 0.7v drop over both transistors, and 3.6v over the LED, totalling 5v, and leaving nothing for a protection resistor. However, for the torch, the control can be placed over the power supply for the circuit.

VR = 9 - (3.6 + 0.7)
VR = 4.7v

R = 4.7 / 0.15
R = 31 = 33R

Step 6: Final Circuit

Below is the final circuit diagram. When implemented, a switch will be placed onto the power supply, and another five LED-resistor pairs will be placed in parallel with the existing pair.

Step 7: Test Circuit

This is a single LED version of the circuit. Not especially tidy, but it is a prototype, and follows the circuit diagram from step 7.

You can also see from the power supply that only 24mA is being drawn, compared with the 30mA if the LED was connected normally.

From the third image containing two LEDs, it appears that both LEDs are of the same brightness. However very quickly, the direct driven LED becomes warm quickly giving good reason to PWM.

Step 8: Finished Torch

Transferring the circuit to veroboard is challenging, especially condensing the relaxation oscillator so it will fit into the case. The main thing to check is that no wires are crossed, or are loose enough to cross. Adding another 5 LEDs, a switch in series with a battery connector and then placing these into a case is more straight-forward.

Connecting the power supply to the battery connector to test the circuit, the average current reading was approximately 85mA. This is significantly smaller than 180mA (6*30mA) that a direct drive system would require.

I have not gone into great detail with transferring the circuit from the breadboard, onto veroboard as I have aimed to concentrate on the theory behind this project, rather than specifically it's production. However as a general guide, you should test the circuit and get it to work on the breadboard, then transfer the components to the veroboard, starting with the smaller components. If you are competent and quick at soldering, you may be able to safely solder a chip directly to board, otherwise you should use a chip holder.



    • Trash to Treasure

      Trash to Treasure
    • Arduino Contest 2019

      Arduino Contest 2019
    • Tape Contest

      Tape Contest

    15 Discussions


    6 years ago on Introduction

    Please put video so that we can see how it looks. How long this light goes in dark?


    Reply 7 years ago on Step 8

    in step 2 there is a i.c. or transistor in the picture? no part no. please reply. thanks


    Reply 7 years ago on Step 8

    No, there is not.

    You can select an NPN transistor based on the current required for the LEDs you are going to use. This selection is a design decision you must make, and I cannot make for you.


    Reply 8 years ago on Step 8

     Thank you very much for replying me, as you can see from my detail, I am a newbie to electronics and just join recently, I have a question about powering up 12  LED, would you mind to have a look of the following link and give me some technological advise please?


    thanks again for your time and advise


    7 years ago on Introduction

    This is a great instrucable! Some very simple and powerful ideas are presented here, Thank you!


    9 years ago on Introduction

    Err... Exactly what is the point of this? Using them normally (without PWM) would yield just as much light? I could see if there was a potentiometer to adjust the frequency and there for the light output, but there isn't.

    3 replies

    Reply 9 years ago on Introduction

    Just because it gives off the same amount of light, it is not unnecessary. It uses far less current as an average, and the LEDs do not heat up anywhere near as quickly.

    And yes, potentiometers could be used to adjust the frequency (Step 2), so long as you ensure the on time is no greater than 10ms.


    Reply 9 years ago on Introduction

    Show me the math. How much energy does this save? Does the IC use as much energy?


    Reply 9 years ago on Introduction

    From observation while testing the relaxation oscillator, the circuit draws approximately 10mA. While off, the LEDs draw no power, and when on, the LEDs draw 150mA each, and so 900mA. Given the duty cycle of 1:10;

    10mA + (10*0mA)/10 + (1*900mA)/10 = 10mA + 0mA + 81mA = 91mA

    As I said above, the power supply gave a reading of about 85mA, so this isn't far off.

    If it was wired up 'normally' then

    6 * 30mA = 180mA

    Adds up to a fairly large saving.


    9 years ago on Introduction

    Nice. Not quite off-topic: PWM is good for model trains, as inertia tends to give unrealistic acceleration from normal controllers. L

    2 replies

    Reply 9 years ago on Introduction

    How do you mean off topic? PWM is good in this instance due to its large (<50%) energy saving.


    Reply 9 years ago on Introduction

    I said "not quite off topic" with reference to the rest of my comment. PWM is good for things, and not just LEDs. L