EXPECTED INITIALIZER BEFORE 'IF'

Hi. I have been attempting some basic if else else if coding and I seem to be doing something wrong. I think it might have to do with the analogPin or threshold but I am not totally sure what those are or how to include them. THANK YOU!

const int ledPin = 13;
void setup()
{
pinMode(ledPin,OUTPUT);
}
void loop()
if (ledPin = LOW)
{
digitalWrite(ledPin,OUTPUT);
}
else
{
digitalWrite(ledPin,LOW);
}

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

elseif:7: error: expected initializer before 'if'
elseif:11: error: expected unqualified-id before 'else'
expected initializer before 'if'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Malformed loop function, no { }, = in place of == used. OUTPUT in place of HIGH should work, but is at least bad style.

const int ledPin = 13;
void setup()
{
  pinMode(ledPin, OUTPUT);
}
void loop() {
  if (ledPin == LOW)
  {
    digitalWrite(ledPin, HIGH);
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
}

Thank you so much! It worked

What do you mean:

  if (ledPin == LOW)

since ledPin always equals 13? LOW always equals zero. When does 13=0?

I am not totally sure myself as I have started coding and arduino itself recently, but I thought that i was saying that if pin 13, or the LED was off, or LOW, to turn it on. Feel free to correct me. Also, when I updated the code to my arduino uno board, it always uses the TX and RX really quickly, then does the command. Thx

You're checking if LedPin is equal to LOW (which is actually just a constant defined as 0). LedPin is 13, not 0, so that will never be true. That's equivilent to if (13 == 0)

You probably meant to read the value on pin 13, and compare THAT to LOW:

if (digitalRead(LedPin)==13)

const int ledPin = 13;
void setup()
{
  pinMode(ledPin, OUTPUT);
}
void loop() {
  if (digitalRead(ledPin) == LOW)
  {
    digitalWrite(ledPin, HIGH);
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
}

Or even:

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite( LED_BUILTIN, !digitalRead(LED_BUILTIN) );
}

Thank you, you three. That all helped and I will build off what you said.