//sketch 06-08
const int outputPin = 3;
void setup()
{
pinMode(outputPin, OUTPUT);
Serial.begin(9600);
Serial.println("Enter Volts 0 to 5");
}
void loop()
{
if (Serial.available() > 0)
{
float volts = Serial.parseFloat();
int pwmValue = volts * 255.0 / 5.0;
analogWrite(outputPin, pwmValue);
}
}
The voltmeter on pin 3, according to the tutorial, indeed shows good results as i type new values on the monitor, but the voltmeter's arm drops back to zero immediately every time.