My question is that can the arduino vary the voltage during a PWM?
[u]PWM[/u] switches between 0 and 5V and you can control the duty cycle to control the average voltage.
You can filter/average the voltage to get variable DC (or AC if the PWM frequency is much higher than the AC frequency). But that's NOT a great way to do it... A digital-to-analog converter (DAC) is a better way to do it. (The "standard" Arduinos have an ADC but no built-in DAC.)