Adjusting Voltage Through Serial Monitor

I'am building simple dac that converts digital signal to analog signal. I'm using arduino mega
I figured out that port manipulation thing on mega (which is kinda confusing). Now I'm trying to input a voltage value on serial monitor to take an output through my circuit.


Thats my circuit,ignore that little wire between resistors

int voltage_input; //voltage value

//int x=0.01960784313725490196078431372549; // i'll use it later application

void setup(){

  Serial.begin(9600);
 Serial.println("Pwm to Analog voltage output");


 
  //set digital pins 42-49 as outputs
  for (int i=42;i<50;i++){
    pinMode(i,OUTPUT);
  }
}

void loop(){

  if (Serial.available()>0)
    {
      voltage_input = Serial.parseInt();
      
    }
    if(voltage_input >0){Serial.println(voltage_input);}
  
  PORTL = voltage_input ;
  
delay(1000);
  }

Problem is parseInt functions time-out blocking me. when i entered a value my multimeter shows that but after 1 sec it disappears, voltage drops to zero.

boolean didItAlready = false;


void loop(){

    if(Serial.available() && !didItAlready){
         val = Serial.read();
         didItAlready = true
    }


   
    // do whatever with your read value

}

on the other hand i adapted this code to my code. it holds the value but i can't enter a new value, it shows the first value and i don't know how to manage.

I can't figure it out anyways, all the topics of "integer to ASCII conversation,parseInt,Serial Communication and yes i read Serial Input Basics - updated - Introductory Tutorials - Arduino Forum " now are purple on my google search.

I just need adjusting my voltage through serial monitor thats all.

I'm kinda new on arduino things and sorry for my bed england...

void loop()
{
   if (Serial.available() > 0)
   {
      voltage_input = Serial.parseInt();
      if (voltage_input > 0)
      {
         Serial.println(voltage_input);
      }
      PORTL = voltage_input ;
      //delay(1000);
   }
}

Only change the voltage out if a new voltage is received. You may want to must make sure that, in serial monitor, line endings is set to no line ending

Solved ! Thx groundFungus. :*

To get rid of the timeout delay, set the line ending in Serial Monitor to something other than "No line ending". Then flush the line ending out of the input buffer after reading the number:

//int x=0.01960784313725490196078431372549; // i'll use it later application


void setup()
{
  Serial.begin(9600);


  //set digital pins 42-49 as outputs
  for (int i = 42; i < 50; i++)
  {
    pinMode(i, OUTPUT);
  }
}


void loop()
{
  if (Serial.available())
  {
    int voltage_input = Serial.parseInt();  // Gather digits until you hit the line ending
    PORTL = voltage_input;
    Serial.println(voltage_input);
    
    // Now flush away the line ending
    while (Serial.available())
    {
      Serial.read();
      delay(2); // For 9600 baud it can take a whole millisecond for the next character to arrive
    }
  }
}

groundFungus:
Only change the voltage out if a new voltage is received. You may want to must make sure that, in serial monitor, line endings is set to no line ending

But that will leave you with the 1-seconds "parseInt" timeout.