LEDFader (backgrounded, non-blocking PWM fader) on 328P-on-a-breadboard flickers

Hello all,

the very talented Jeremy offers a nice library at GitHub - jgillick/arduino-LEDFader: An arduino library to fade individual LEDs in the background without blocking your main program. that does LED fades in the background, non-blocking. Works like a charm on a normal Arduino, but I'd like to take this library and use it on my 8MHz 328-on-a-breadbord as per http://arduino.cc/en/Tutorial/ArduinoToBreadboard.

Doing so results in flickering of the LEDs (and perceived about half the speed), I assume because the µC runs at 8 instead of 16 MHz.

F_CPU seems to be correct (as delay() and friends work reasonable well, ie. within the boundaries of using the internal oscillator and no crystal).

Any ideas where else to change something to adjust the library to 8MHz? I have contacted the author himself but he had no further ideas, so I turn to you.

Thanks,
Christian.

Might be hardware.

Are you using resistors on your LEDS?
I suggest putting a pullup resistor from Reset to +VCC
Are you using capacitors across VCC?
Is your incoming voltage reasonably clean?

I ran the LEDFader library on an attiny85 @8MHz and it runs fine. I also tried it with an Arduino Pro Mini @8MHz and works fine.

It's probably some loose or bad connections on the breadboard. Try a different breadboard or changing out some wires.

Well, it seems to have been neither of your suggestions; I checked my power, used a smoothing capacitor and installed (another) resistor. No avail.

I then changed the pin - from Arduino 3 (which should be a PWM pin) to Arduino 6 (port D7 / chip pin 12) - and voila, it worked. Albeit very slow, but not flickering anymore (and yes, I checked with two other/unused ATmegas if my chip might be broken).

The slowness prevails- setting #define FADE_TIME 1000 still takes a good 16 seconds. Any further good ideas?

ctshh:
The slowness prevails- setting #define FADE_TIME 1000 still takes a good 16 seconds. Any further good ideas?

It may be the mega328p fuse bit settings may not be set correctly. I'm sure you did, but I'll ask anyway, did you burn bootloader to set the fuse bits? This is necessary to set the proper clock rates for 8MHz.

Also, just to verify pin D3 (PWM) is physical chip pin-5.