(I'll move the PWM LED posts to an off-topic thread in a few minutes to keep this about Chuck's code example. I just want to put down some comments first.)
I was hoping you wouldn't see that.It was late and I went to bed.
Usually I'd agree with you, and yes I'm aware of the current limitations on PICs and pins.
But ... LEDs are special. You can get different performance out of them via PWM. This is identical LEDs:
- left, 5V rail with 270ohm resistor.
- right, PWM without resistor.
I can get identical brightness with 2.5mA less. If I add a 270 ohm resistor to PWM, I get 1/2 the current.
Yeah, I thought I could improve this even further down to 2mA but that isn't gonna happen. The LED won't be bright enough.
And yes, I've been playing with using transistors/MOSFETs and I'll be going back that way again.
I had dropped that idea cause HPWM has lower limits on Frequencies and I didn't like not have total control (64 MHz is 3905Hz).
But I just realized I could pulse the devices using a timer interrupt; switching between different ON-time and OFF-time.
Bookmarks