errors, errors and more errors

Adding, it's far better to read once and store in a variable. E.g.

int val = analogread(A0);
if (val >= 500 && val <600)
{
  // do something
}

There are two advantages: analogRead takes approx. 100 uS so only reading once speeds up the process. And in those 100 uS the input signal might have changed and you would have been comparing two different readings if you used two analogReads.