"if" code runs when it's not supposed to

Issue: I'm using a thermistor to measure the air temperature. When it gets above 84, I want a red LED light to turn on, and once it goes back down to 84, I want the LED light to turn off. However, when I run my Arduino the LED light turns on for 1 second and off for 0.2 seconds, no matter what the temperature is.

Here is my code:

int led = 13;

void setup()
{
  pinMode(led, OUTPUT);
  Serial.begin(9600);      //Set serial baud rate to 9600 bps
}

void loop()
{
  int val;
  val=analogRead(0);      //Read value from analog 0
  Serial.print("Val=");
  Serial.println(val,DEC);    //Print the value to serial port
  delay(200);

  if(val >84);
  {
    digitalWrite(led, HIGH);
    delay(1000); // wait for a second
  }
  digitalWrite(led, LOW);
}

Get rid of the ; after your if. Also read up on if-else syntax

Short of a else-statement

if(val >84)
  {
    digitalWrite(led, HIGH);
    delay(1000); // wait for a second
  }
   else
   {

     digitalWrite(led, LOW);
   }

Or you could write this way

if(val >84)
  {
    digitalWrite(led, HIGH);
    delay(1000); // wait for a second
  }
   if(val<=84)
   {

     digitalWrite(led, LOW);
   }

@Ran12345,

You've got a serious error in your code there. If you try to compile that you'll get an "else without a previous if" error.

Delta_G:
@Ran12345,

You've got a serious error in your code there. If you try to compile that you'll get an "else without a previous if" error.

I don't really understand it. Why would i get an error for an else without a previous if? I have an if before a else in the code.

No, you don't. You have an if and then some unconditional lines and then an else. You can't put extra lines of code between the if block and the else.

Oh, you edited the code since I posted. That is ugly thing to do to fix the mistake I pointed out and then claim you don't know what I'm talking about. Dirty trick that is. You know what you screwed up and you fixed it after I pointed it out. You should have said oh thanks I'll fix it. Or at least make it clear that you changed that after I posted. I know you're new here. Don't get started on the wrong foot. Have some integrity.

Delta_G:
No, you don't. You have an if and then some unconditional lines and then an else. You can't put extra lines of code between the if block and the else.

Oh, you edited the code since I posted. That is ugly thing to do to fix the mistake I pointed out and then claim you don't know what I'm talking about. Dirty trick that is. You know what you screwed up and you fixed it after I pointed it out. You should have said oh thanks I'll fix it. Or at least make it clear that you changed that after I posted. I know you're new here. Don't get started on the wrong foot. Have some integrity.

Nope, I have removed the extra lines "could write this way" before your post and just now, I just edited the ";" this after your post. and the error pointed out is not putting the else before an if but putting "//" to comment the words.

In fact, I'm just posting 2 alternative codes for the person and not 1 full code.

Right you edited out the ; after my post. And that's the error I was pointing to. Go load it up and see what error it gives.

If someone posts about your code and then you edit it after the post, then mark it as such. Don't edit it and then pretend it was right all along.

You removed the semicolon I told the OP to remove in post #1. You had the same error as the OP.