Keep variable value until serial input is changed

I found this code from Send data from a computer to an Arduino - Suffix

int ledPin = 13;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char value = Serial.read();
    if (value == '1') {
      digitalWrite(ledPin, HIGH);
    } else {
      digitalWrite(ledPin, LOW);
    }
    Serial.println(value);
  }
  delay(1000);
}

It turns on the onboard LED when you type '1' in the serial monitor, and off when you type anything else.

However, the LED turns off on its own since the serial monitor returns to a default value immediately.

Does anybody know a way to make the LED stay on until you type something else in?

However, the LED turns off on its own since the serial monitor returns to a default value immediately.

More likely, you're sending carriage-return/line-feed.

AWOL:

However, the LED turns off on its own since the serial monitor returns to a default value immediately.

More likely, you're sending carriage-return/line-feed.

Is this an answer?

Is this an answer?

It's a hint for you to tell us what is sending the serial data to the Arduino, and how. If you are using the Serial Monitor, what option have you selected (at the bottom)?

PaulS:
It's a hint for you to tell us what is sending the serial data to the Arduino, and how. If you are using the Serial Monitor, what option have you selected (at the bottom)?

'Carriage Return' is selected

So, every time you type something, the serial monitor sends that and a carriage return. A carriage return is not a '1', so the LED turns off.

There are other options...

PaulS:
There are other options...

Like...

Like selecting an option that does not add an extra character or 2

UKHeliBob:
Like selecting an option that does not add an extra character or 2

Can you please explain in detail?

Can you please explain in detail?

Can't you look at the list of options and figure that "No line ending" adds nothing, that "CR only" and "Line feed only" add one character, and that "Both CR and LF" adds two characters?

If not, can't you try all 4 options, and see if one of them allows the LED to stay on?

Okay, I realized No Line Ending does it.