how to control a DC supply's voltage using a micro controller
What you need is the equivalent of an adjustable power regulator. There are multiple ways of doing this though:

1. Using a switch-mode buck converter topology

This is the simplest to implement with a microcontroller as long as your microcontroller have both ADC input and PWM output.







simulate this circuit &ndash; Schematic created using CircuitLab

Power MOSFET M2, D1, and L1 makes the buck converter. Signal MOSFET M1 is used as a level shifter and gate driver. Resistive divider R2 and R3 allows your MCU to sample the output voltage and control the PWM signal as required.

2. Use a linear regulator topology

I would not recommend using this topology as it requires more complicated control, more chips and have worse efficiency than the switch-mode supply above.

You need to have an DAC to generate the target voltage and use op-amp and emitter follower to amplify the DAC output.