I don't know what microcontroller your are using, but assuming it doesn't have a true hardware DAC, you can use a pwm function with a low pass filter to achieve a crude DAC. You are limited to your pwm resolution and you have to be sure that you don't load the filter too much or else its output will drop.