use pwm, just ramp up and down with a counter and put a filter on the pin (RC).