While the Arduino Uno cannot output a continuously varying(analog) voltage, it can simulate this using analogWrite
for example:
analogWrite(3, 128); //sets pin 3 to half-brightness.
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Related:
Substitute a DC Motor for the LED- Knob controls the motor speed
// the setup routine runs once when you press reset:
int motorPin = 12;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);// read the input on analog pin 0:
analogWrite(motorPin, sensorValue / 4);//analog out is 0 to 1053;
//analogWrite is 0 to 255
}