I wanted to try your project on my Arduino uno.
On the hardware side all I did was plug to insert two photoresistors (CdS), one with its leads into A0 and +5V and the other into A0 and ground. This is just a voltage divider circuit of two variable resistors connected between +5 and ground, with a tap from between them to analog port A0.
Here was the Arduino C program to drive it. It worked OK and outputs the time in milliseconds. To start timing, I covered the first sensor (eg ball rolling past sensor) and to stop timing I covered the second sensor (ball rolling past second "eye"). This program can be improved (eg it takes no account of thickness of ball or time C commands take to execute) but it is a start.
I checked the analog values the sensors gave first, and if one was covered it had values about 40 and if the other was covered it read 200.
Here was the program...
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
int count = 0; //set up your timing counter
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
if (outputValue <100) // you are covering the start semsor
{count = 0;} // start the time count
//{Serial.println(outputValue);}
if (outputValue >200) // you are covering the out sensor
{Serial.println(count);} // write the time in milliseconds to serial monitor
delay(10); // delay 10 microseconds
count = count + 10; // update the time counter by 10 microseconds
}