PortD setting value but going back to 0 after 2 seconds

Hi There!

I am trying to write on PORTD the number received by Serial (USB).
I am not using the first 2 bits of PORTD (used by Serial TX and RX transmission).

Every PORTD pin (Digital 0-7) is connected to a resistor 220 Ohms and LED.

When I write on the Serial Terminal the value I want to write on the PORTD, it appears on the LEDs.
That’s OK, however after around 1-2 seconds it is coming back to 0. and the LED is OFF.
Do you know why is it happening?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>



int data;

void setup() {
 
  Serial.begin(115200);   
  DDRD = DDRD | B11111100;  // this is safer as it sets pins 2 to 7 as outputs
                    // without changing the value of pins 0 & 1, which are RX & TX 
  PORTD=0;
  data=0;
}



void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available()>0) {
        data = Serial.parseInt();     
        PORTD= data<<2;
    }
    
}

Sounds like there is serial data of some sort after your number, so you get to the parseint a second time. But there is no full number, so it times out and returns 0 (or -1, or some otherwise unexpected value.)

At bottom of serial monitor, make sure LINE ENDING is set to NONE.

That's it,
Changing LINE ENDING to NONE solved the problem.
Thanks!