Second value of Serial.println() is always 0

Second value of Serial.println() is always 0, even though I did not enter value 0.

what happening is ...
when ever I enter a value(eg: 45) in serial monitor, it's printing the value(45) and 0 .
I don't know why 0 is getting print every time
Can anyone say why this is happening?
(I'm new to arduino)

don't post image of text... just post the text...

likely your issue is due to the newline you send at the end. parseInt() with stop at the new line and then when you come back the Serial buffer is not empty so you proceed and parseInt fails and thus returns 0

I would suggest to study Serial Input Basics to handle this

What have you got Line ending set to in the Serial monitor ?

Please follow the advice given in the link below when posting code . Use code tags when posting code here to make it easier to read and copy for examination

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