Pin 0 on Arduino UNO board won't stay LOW

I’m using a UNO board and trying to set Pin 0 LOW. It briefly flickers low then reverts back to being high and just sticks there. I have nothing connected to 0. What am I missing? :~

I am expecting Pin 0 to stay LOW after sending “x” in the serial monitor. My loop keeps sending the count, so I know my code isn’t frozen.

My code:

const int pin0 = 0;

int cntr = 0;

void setup() {
  pinMode(pin0, OUTPUT);
  digitalWrite(pin0, LOW);
  
  Serial.begin(9600);
  delay(2);
  Serial.println("X to start\n");
  while (Serial.read() <= 0) {}
  delay(400);
}

void loop() {
    Serial.println(String(cntr));
    digitalWrite(pin0, LOW);
    delay(1000);
    digitalWrite(pin0, HIGH);
    delay(1000);
    cntr += 1;
}

nelsonhoover: I have nothing connected to 0.

Oh but you do. Serial. You can use pin 0 for I/O. Or you can use pin 0 for Serial. You cannot do both.

So the output to the Serial monitor is sent via Pin 0? OK. Guess I'll need to find another pin.

Thanks. I'm just starting with Arduinos and knew I was probably missing something fairly simple.

If you look at the markings on the board, you'll see that pins 0 and 1 and both used for serial comms: Rx and Tx respectively.