My code output kept changing itself. How can I fix it?

I have written a code that generates PWM to control LED. Duty cycle is from 0 to 100% (0 = lowest, 100 = highest).
I am using serial monitor to input any number from 0 to 100.
Every time I input a number. For example: if I input 50, serial monitor would read 50, then it would change to 0 as you can see below. How can I prevent this from changing.


Here is my code:
PWM generation.ino (519 Bytes)

Thanks for the article! It works. Is there any way of writing the code for "no line ending"

Hi, @gkalongo2019
Welcome to the forum.

To add code please click this link;

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Just set this in the monitor....