while compare, something is wrong I have 5 LDR and Arduino Mega. I connect them and get light level.

void loop() {
// print the analog output in milli volts
int w=analogRead(west);
Serial.print("west = ");

Serial.print(w);
Serial.println(" mv");

int e=analogRead(east);
Serial.print("east = ");

Serial.print(e);
Serial.println(" mv");

int n=analogRead(north);
Serial.print("north = ");

Serial.print(n);
Serial.println(" mv");

int s=analogRead(south);
Serial.print("south = ");

Serial.print(s);
Serial.println(" mv");

int c=analogRead(control);
Serial.print("control = ");

Serial.print(c);
Serial.println(" mv");

delay(1000);

if(e &gt; w)
Serial.println("west");

else if(e &lt; w)
Serial.println("east");

else if(s &gt; n)
Serial.println("south");

else(s &lt; n);
Serial.println("north");

Serial.println("\n");
}


This is my loop and I always see east-north. When west is bigger than east I also see east. What
Nick Gammon correctly points out a problem due to an extra semicolon, but you should also note what the construct else(s &lt; n) is doing.  When the if condition that this else gives an alternative to is false, the statement   (s &lt; n) gets executed.  That statement is an expression statement, and its value is the evaluation of s&lt;n, either true or false.  

If the semicolon after (s &lt; n) weren't there, you'd get a compile error because (s &lt; n) serial.println("north") is not a valid statement.  You may have meant to say else if(s &lt; n) instead of else(s &lt; n).

Note, in the sequence

if (e &gt; w)
   Serial.println("west");
else if (e &lt; w)
   Serial.println("east");
else if (s &gt; n)
   ...


that last else typically is reached only rarely, because the only condition to get to it is e and w being equal.  Due to sensor noise and signal processing noise, the chance of e and w being equal is probably at most a few percent.

If your north/south test sequence is supposed to be independent of your east/west test sequence, leave out the second if and second else .  That is, instead say:

if (e &gt; w)
   Serial.println("west");
else
   Serial.println("east");
if (s &gt; n)
   ...