I have had trouble with this for the past week and nothing I have been doing works. I've tried replacing the photosensors and change the wiring, but I've never had any success.
There is something wrong with your code. You are not reading the sensor value continuously in the loop. There are few loopholes in the code.
int F = analogRead(Flat); int S = analogRead(Sharp);
You are reading the analog value outside the loop() function. This is not the right way of writing code. your code will not execute without including the code under the setup() or loop() function. setup() function code will run only once and loop() function code will run repeatedly.
So you have to include the sensor reading code within the loop() function.