Using the Serial Monitor with Serial.read() and Serial.parseInt() in the same code

Try:

void loop()
{
   if (Serial.available() > 0)
   {
      int val = Serial.parseInt();
      Serial.print(val);
      analogWrite(DAC0, val);
   }
}

The serial input basics tutorial may be of interest.

1 Like