Using Capacitor to Fade LED, Shiftout()

Hello,

I'm following this tutorial ( http://www.arduino.cc/en/Tutorial/ShiftOut ) and I want to be able to fade a set of LEDs out with hardware rather than code. What sort of capacitor can I use to achieve this? Thanks.

Use a variable resistor attached to each LED. This will allow you to limit current and therefore decrease brightness.

Using a bunch of variable resistors like this is not a very cost effective solution (which is why doing it is S/W is generally better).

Do you want them all to fade at the same rate? Is it a fixed rate (i.e., it should always take, say, 2 seconds for them to "fade to black")?

What I'm thinking might work for you is this:

  1. Pick a circuit off the web that generates triangle or sawtooth waves.

  2. Put a capacitor and a resistor in parallel. Adjust the values so the discharge time matches your desired fade-out time.

  3. Charge up the cap by connecting an Arduino pin to it through a diode. Set the pin as a HIGH output to charge the cap, then set it low. The diode will keep the Arduino from discharging the cap (much: there will be a tiny amount of leakage through the diode. You should pick your R and C values so the leakage current is insignificant). If the cap is really big, you might also need a series resistor between it and the Arduino, to make sure it doesn't suck so much current during charge-up that it fries the output pin.

  4. Feed the triangle/sawtooth and the voltage at the top of the cap into a comparator. That will give you a gradually-decreasing duty cycle PWM that you can feed to the "enable" pin on your shift register(s).

Ran

Thanks for your responses. Yes, they will be fading at the same rate. I would like to have the effect of one light on and as it starts to fade out and is almost fully off the next turns on and so on, creating a seemless transition. Ran, I'm a bit of a noob when it comes to electronics. I found a sawtooth diagram online ( http://freecircuitdiagram.com/wp-content/uploads/2009/05/sawtooth-wave-oscillator.gif ) but I'm not quite sure how I would add a shift register into the schematic. Also could I add a Potentimeter into the circuit to be able to control the fade out time that way?