PWM signal stops

//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.

What is the serial monitor line ending?
It should be "none"

Please remember to use code tags when posting code

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.