When using a microcontroller and want to drive motor control or controlled intensity, you can use DAC to generate an analog output voltage. But there is an easier way of doing this. You can use a digital output to reach the same results. This technique is known as PWM -Pulse Width Modulation.
In this picture, you can see a 50% duty cycle square waveform. The width of ‘0’ is equal to the ‘1’ level. This means if the signal amplitude is 5V, then the average voltage over one cycle is 2.5V. It is as though of hawing constant 2.5V voltage.
If you have 10% duty cycle, then your average voltage would be 0.5V.
You should use low pass filter to convert pulses to analog voltage:
This is like digital to analog converter without DAC.
You can use PWM to drive LED to change light intensities. Also, it can be used to generate audio by changing the frequency of the duty cycle. DC motors can also be controlled effectively by PWM.