Maker Pro
Maker Pro

Making a Pulsing/Fading LED Circuit

hevans1944

Hop - AC8NS
Jun 21, 2012
4,878
Joined
Jun 21, 2012
Messages
4,878
The circuit which appears to have the best fade appearance, and I believe has the curved saw-tooth wave of which you mention, is the best one out of the three I have setup.
That circuit IS NOT what I would recommend, especially if you have an Arduino Uno handy to play with. The curvy saw-tooth waveform is horribly inefficient and most of the power is wasted as heat in the transistor. This circuit cannot be easily expanded to drive more than one or two LEDs.

First master, using the built-in PWM capability of the Arduino platform, how to use PWM to drive a single bit on a single output port with a software-controlled PWM signal. Use that PWM output bit to drive the gate of a MOSFET, whose source is connected to logic common of the Arduino.

Connect LEDs (one or more in series), along with a series-connected current-limiting resistor, to the drain of the MOSFET, anodes pointing toward the positive supply. Start with a 150 to 200 ohm, 1/4-watt, current limiting resistor if you are using +5V DC to power up the Arduino. That voltage will limit how many LEDs you can connect in series, but two or even three red LEDs should be okay.

Even if a MOSFET could be driven to zero resistance when turned on by a positive voltage applied to its gate, the forward voltage drop across each LED subtracts from the available supply voltage. The LED forward voltage drop at full illumination power depends on the color of the light emitted. Red LEDs have the smallest forward voltage drop; so-called "white" LEDs have the largest.

You can add more series-connected LEDs, each with a single current-limiting resistor in series, between the drain and the +5V DC supply, these added "extra" LEDs are essentially additional loads connected in parallel with the original LED string. The maximum number of these "extra" LED strings you can have is dependent only on the current sinking capability of the MOSFET and the current sourcing capability of the +5V DC supply.

Remember, you cannot connect LEDs directly in parallel. There must be a current limiting resistor in series with the series-connected LEDs before each string can be added as a parallel additional load between the MOSFET drain and the +5V DC supply. But this is where the PWM circuit really shines, compared to the curvy sawtooth: you can add as many LEDs as you want as long as the power supply and MOSFET can handle the current.

You can use an NPN bipolar junction transistor (BJT) instead of a MOSFET. To make sure the transistor saturates when it is turned on, use a 1000 ohm resistor connected between its base terminal and the Arduino PWM output. To make sure the transistor turns off, place a 10,000 ohm resistor between its base terminal and its grounded emitter terminal. The collector terminal is wired the same as the drain terminal of the MOSFET.

In software, you can set the PWM duty cycle to 100 percent to turn the LEDs on or 0 percent to turn the LEDs off. Again in software, you can vary the PWM duty cycle from 100 percent down to 0 percent to fade the LEDs to off, or from 0 percent to 100 percent to brighten the LEDs to full on.

There are interesting variations you can implement with software, such as varying the rate at which the LEDs are dimmed or brightened based on the setting of an external potentiometer, as read by the Arduino built-in analog-to-digital converter. You could also program an input bit to determine how manipulating the external potentiometer to behave: switch "on" could be interpreted by your program to mean the potentiometer controls the PWM duty cycle, effectively controlling the maximum brightness of the LEDs. Switch "off" could be interpreted to mean the potentiometer controls how rapidly the LEDs fade in and out. Of course you would want to periodically store the digitized potentiometer value for use after the switch position is changed from "off" to "on" or vice versa.

You don't have to use an Arduino to implement PWM. There are plenty of circuits available on the Internet that will show you how to implement PWM with a 555 timer IC.

BTW, I am not getting a warm, fuzzy, feeling that you understand any of what I have written above. Simulation has its place, but you have to construct real circuits with real components to obtain any real understanding of what is going on, or how to make it happen. Have you accumulated any parts to breadboard circuits with?
 
Top