Instructables
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.
 
Remove these adsRemove these ads by Signing Up

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.
chetancc2 years ago
Please put video so that we can see how it looks. How long this light goes in dark?
luckyvictor4 years ago
 so your LED are connected in parallel??
mathews (author)  luckyvictor4 years ago
Yes, each with its own current limiting resistor.
recuat mathews2 years ago
in step 2 there is a i.c. or transistor in the picture? no part no. please reply. thanks
mathews (author)  recuat2 years ago
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.
 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?

http://www.instructables.com/answers/Power-for-12-LED/

thanks again for your time and advise
fobot3 years ago
This is a great instrucable! Some very simple and powerful ideas are presented here, Thank you!
heaker893 years ago
where put the switch?
Padlock5 years ago
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.
mathews (author)  Padlock5 years ago
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.
Padlock mathews5 years ago
Show me the math. How much energy does this save? Does the IC use as much energy?
mathews (author)  Padlock5 years ago
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.
lemonie5 years ago
Nice. Not quite off-topic: PWM is good for model trains, as inertia tends to give unrealistic acceleration from normal controllers. L
mathews (author)  lemonie5 years ago
How do you mean off topic? PWM is good in this instance due to its large (<50%) energy saving.
lemonie mathews5 years ago
I said "not quite off topic" with reference to the rest of my comment. PWM is good for things, and not just LEDs. L