I am using a '509 to read a pot and output a PWM on one of the ports for LED dimming. I charge a cap then measure the discharge time through the pot for the A/D conversion. It works, but my code is clunky and too slow to do the PWM at a high enough frequency. Someone out there must have already done this. Any code or advice would be appreciated.