Photo Resistor

I am trying to use the Arduino to calculate the velocity of an object. To do this I am using two photo resistors as my sensors. As the object passes over the photo resistor it reads the value and when it is below a certain value it the Arduino starts the time. then as it passes over the second sensor and the Arduino saves the end time. After that the code calculates the velocity. However i am running into a problem in which the sensors are either not reading or only one of them. I have adjusted the threshold multiple times in an effort to get the sensors more accurate. I have also tested the value at which they are reading. the sesnorvalue1 is around 1000 and the sensorvalue2 is around 550. Any ideas to fix this issue would be great.

the code is as follows:

int sensor1Value;
int sensor2Value;
double startTime;
double endTime;
double time;
double timeInSeconds;
double distance;
double speed;
boolean endFlag;

void setup() {
distance = 6; //In cm
endFlag = false;

void loop() {
//sensor1Value = analogRead(A1);
sensor2Value = analogRead(A0);

Serial.println(sensor1Value); // Used for determining photoresistor thresholds

if(sensor1Value < 1000){ // If first photoresistor passes threshold, save startTime.
endFlag = false;
startTime = millis();

if(sensor2Value < 600 && endFlag == false){ // If second photoresistor passes threshold, save endTime.
endTime = millis();
time = endTime - startTime;
timeInSeconds = time/1000; //Converts time in milliseconds to seconds
speed = distance/timeInSeconds;
Serial.print("Speed: ");
Serial.print(" cm/s");
Serial.println(" ");
endFlag = true;

Always use code tags when posting code, so that it looks like this:

//sensor1Value = analogRead(A1);

which line, incidentally, is a comment (due to the "//" at the beginning) and therefore does not read sensor1Value.

Photoresistors are too slow to detect anything much faster than walking pace movements. You need to use a photodiode or phototransistor to time rapid motion.

Finally, ALWAYS use unsigned long declarations for millis() or micros() related variables. This won't work in general:

double startTime;
double endTime;

Wired with the correct resistor value you can read LDRs as digital input. Experiment a bit. >3V on the pin is reliably read as high; <1.5V is reliably read as low (assuming 5V Arduino).

They're indeed slow (0.2 second reaction time or so) - how fast is your object, and how long does it cover each sensor?

Double is an alias of float in regular Arduino (8-bit AVR processor). 4 bytes, 6-7 significant digits.