serial monitor reading zero on its own

I am using a Arduino uno and am facing a problem with reading from serial monitor when I type a number in serial monitor and click send it displays the number I sent and then it automatically takes zero as the next number.
So can you please help me with this..

arduino.pdf.ino (284 Bytes)

Turn off the line ending setting in the serial monitor (set to no line ending)

Or better yet, read Robin2's tutorial Serial Input Basics to see how to do it better.

Serial.println(r);

aarg:
Turn off the line ending setting in the serial monitor (set to no line ending)

@OP
This is the layout of Serial Monitor (Fig-1). Look for the 'Line ending tab' and choose 'No line ending' option. Also, change this line: Serial.print(r); to this line: Serial.println(r); to get the nicer format of your message on the OutputBox of Serial Monitor (Fig-2).


Figure-1:

smmulti.png
Figure-2:

smmulti.png

1 Like

thank you very much for your help sir!!!