Using a Flux Capacitor to fade an LED

Hi Guys,

This question is a follow on from this one - Fine control of an LED - Programming Questions - Arduino Forum that I posted in Programming.

I was seeking a way to have a smoother LED fade, and implemented many of the suggestions that were made, I now have a non linear fade (more of a fade curve) which looks a lot more natural, the problem im still experiencing is the noticeable steps in brightness as digitalWrite() gets below 10, especially step 1 to 0.

I was thinking of using a 470uF capacitor that would allow the LED to fade in a smoother way, unfortunately my setup includes the LED blinking in a random arrangement prior to fading, and the capacitor messes this up by discharging during the blinking stage.

My other thought was to have the capacitor connected to a separate output pin (a different one than the LED is connected to), and when digitalWrite() gets to zero, the capacitor would then discharge, creating a smooth fade to black.

Ive looked at lots of examples but cant find anything similar, not even sure if its possible. I would normally test most of my theories out myself before asking for help, but with the possibility of a capacitor discharging and frying my arduino, I thought its best to ask before blindly experimenting.

A capacitor will mess it up anyway :slight_smile: And I think you mean analogWrite()? :wink:

The most straightforward way would be to use PWM with more resolution. For example use the PCA9685, that's 12-bit instead of 8-bit a standard Arduino uses. That makes that a step is 1/16th of the size now.

. . . also post the code that emerged at the end of your last thread: Fine control of an LED - Programming Questions - Arduino Forum

Hi septillion,

oops, correct I did mean analogWrite().

I read about the PCA9685 in an old thread regarding higher resolutions, I was just hoping to solve the problem with the kit I have. Thinking back, I think you may have been part of that thread.

Smooth fade, smooth fade, my kingdom for smooth fade.

I doubt you have anywhere near sufficient power (1.21 GW) to activate a flux capacitor. :astonished: