Altered code to work with programmable PWM pulse-width resolutions