really weird array behaviour

This sketch is trying to read the analog values from the opamp on two PIR sensors.
I knew this would be tricky, but my serial monitor output shows state[2] gets given the last value from A0.
Except after a CCW motor trigger, when both state[1] and state [2] are reset to 0.
Which can be seen on the serial monitor, so I know it is not a formatting issue.

Of course the simulated motor response is not as expected, with the CCW motor going off most of the time.
CW motor does trigger very occasionally , I assume only when the A0 value happens to be just 1?

//I have two PIR sensor boards with 4 hole masks rotated offset by half hole spacing.

//Each PIR then has four areas, alternating with the other PIR, where IR from a moving hand can be sensed.
//I take the output from the second stage amp and feed it into the Arduino ADC input.
//Now similar to detecting press order with two buttons.
//Is the movement of the hand CW or CCW?.
//The values need to be polled.
//Array state[] stores flag = 1 if any movement detected.
int state[2];
int val1 = 0;
int val2 = 0;
int noise = 100;

void setup()
{
Serial.begin(9600);
pinMode (13,OUTPUT);//Led monitor
digitalWrite(13,LOW);
state[1] = 0;
state[2] = 0;
}

void motorCW()
{
  state[1] = 0;
  state[2] = 0;
  for (int counter = 0;counter<5;counter++)
  {digitalWrite(13,HIGH);
  delay(200);
  digitalWrite(13,LOW);
  delay(200);
  }
}

void motorCCW()
{
  state[1] = 0;
  state[2] = 0;
  for (int counter = 0;counter<2;counter++)
  {digitalWrite(13,HIGH);
  delay(500);
  digitalWrite(13,LOW);
  delay(500);
  }
}
void loop()
{  
  //final sketch will wake from sleep with interrupt from one PIR normal output//
  for (int wait = 0;wait<5000;wait++)
  //this is the stay awake time to conserve battery power
  {
    val1 = analogRead(A0);
    if (val1 > (338 + noise)){state[1] = 1;}
    if (val1 < (338 - noise)){state[1] = 1;}
    if ((state[1] == 1) && (state[2] == 1))
  {motorCW();}
    Serial.print("A0 input:  ");
    Serial.println(val1);
    Serial.print("state[1]:  ");
    Serial.println(state[1]);
    Serial.print("state[2]:  ");
    Serial.println(state[2]);
    delay(1000);
    val2 = analogRead(A1);
    if (val2 > (338 + noise)){state[2] = 1;}
    if (val2 < (338 - noise)){state[2] = 1;}
    if ((state[2] == 1) && (state[1] == 1))
  {motorCCW();}
    Serial.print("A1 input:  ");
    Serial.println(val2);
    Serial.print("state[1]:  ");
    Serial.println(state[1]);
    Serial.print("state[2]:  ");
    Serial.println(state[2]);
    delay(1000);
  }
}

Arrays are zero based. So, int array[2] can contains array[0] and array[1] (2 elements).

Nothing at all weird about it.

Whoops!
Yes, arrays begin at zero, thanks for spotting that obvious one.