void setup()
{
  pinMode(4, OUTPUT);
}

void loop()
{
  int iAnalog;

  for(;;)
  {
    iAnalog=analogRead(0);
    if (iAnalog<500)
    {
      digitalWrite(4, LOW);
    }
    else
    {
      digitalWrite(4, HIGH);
    }
  }

  for (;;)
  {
    digitalWrite(4, HIGH);
    delay(200);
    digitalWrite(4, LOW);
    delay(200);
  }

}

Loading
esp32-c3-devkitm-1