help using a encoder sensor

hi, im new here and with the arduino ..i have little arduino programing knowledge . so i made a sort of reflective sensor using a phototransistor and ir led and i want it to count an encoder strip with black and white lines .i hav made a code:
int count = 0 ;
void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
Serial.println(count, DEC);
if (sensorValue < 1000)
{
count = count + 1;
delay (1000);
}
else
{
count = count + 0;
}
}


this counts the number of white lines it sees but there is one problem i want it to increase count one time when it sees a white line but now if i keep a white line on the sensor it keeps on counting? who can i limit one count per white line??

How about something like:

uint8_t isWhite=0;
void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(count, DEC);
  if ((sensorValue < 1000) && !isWhite) {
    count = count + 1;
    isWhite = 1;
  } else if (isWhite) {
    isWhite = 0;
  }
}

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

thanks for posting the code i checked t but it doesnt work it keeps on counting even when im on the same strip of white?

yes i think its also important to mention that its a white black white(and so on) strip .so when t sees a black strip the output is around 1022-1023..