Use PWM and and ramp that up or down over a time period.