Preferably without needing to use any additional circuitry
Search for PWM_lib or TC_lib from antodom.