How to emulate a capacitor discharge curve using a microcontroller output pin?
A recursive difference equation
Vo(t+1)  = Vo(t) * K, where 0  &lt; K  &lt; 1
will provide that decaying out, as a number.
To provide the  actual voltage, use the number to set the duty cycle of a PWM
PULSE WIDTH MODULATOR, and use an RC low pass filter to remove (most of) the pulsation, and keep just the computer_controlled voltage.
=========================================
If you discharge a capacitor with a Constant Current, you produce a linear ramp.

dV/dT = I / C, where 1uA and 1uF produce a (linear) ramp of 1 volt per second.