DAC using Arduino Leonardo
Yes you are going in the right direction.

Comparators
You haven't as yet detailed how you plan to connect the 2 comparators to the Arduino, but I imagine it would be something similar to this:







simulate this circuit &ndash; Schematic created using CircuitLab

In the circuit above, X and Y are either high or low based on the analog voltages of A, B, C &amp; D. I have created a truth table below with some arbitrary voltages to output. The value column corresponds to the value needed for the analogWrite() function.



Note: If you need your analog output to be able to source some current you can add an Op-Amp in a unity gain configuration at the output of the RC filter.



Examples To Read
To output the analog value, the 4 best suited inbuilt examples/tutorials to look at are:

Dimmer: Send serial values to change the brightness of an LED.
Fading: Use an analog output (PWM pin) to fade an LED.
Analog In Out Serial: Read an analog input pin, map the result, and then use that data to dim or brighten an LED.
Read ASCII String: Parse a comma-separated string of integers to fade an LED.  

What all of these examples have in common is the analogWrite() function:

// writes the analog value (range from 0 to 255):
analogWrite(pin, value);


Dimmer is a simple example where a serial value is read and then output on one of the PWM pins.
Fading is probably the most basic example of using the analogWrite() function (PWM output).
I included Analog In Out Serial as it uses the map() command.
I included Read ASCII String as it shows how to parse multiple values on the serial string.



PWM Pins
You can use pins 3, 5, 6, 9, 10, 11, and 13 on the Arduino Leonardo to output the PWM using the analogWrite() function.



Control
I recommend the following tutorials for your control. You could either use the if-else command or the switch-case command.