counting ADC samples ( using a light sensor)
There are 2 common light sensor types.  The photo diode and the photo resistor.  The first produces small amounts of current and operates fast.  The second changes resistance and operates (very) slowly.

There is a good stack exchange response here for how to use a photo diode.  Often the photo diode output is small and additional hardware is used to amplify the signal.  As discussed in this stack exchange response.

The photo resistor or cadmium sulphide cell or Light Dependent Resistor is much easier to interface with an Arduino.  However, the response time is very slow.  On the order of hundreds of milliseconds to seconds.  This is acceptable when controlling street lights.  But is not acceptable in applications requiring fast light detectors such as those used for communication.

Before going on, verify which device you are using in your design.

Generally, Arduinos contain a 10 bit ADC.  This results in values from 0 to 210−1 or 0 to 1023.  Should you consistently get a reading at or near the limits of the ADC check your hardware.  Do this by measuring the voltage at the input of the ADC pin used.  Do this under varying conditions to verify the hardware is operating as expected.

A good software design uses hysteresis to convert an analog value to a logical 1 or 0.  Here is a stack exchange response about using hysteresis with Arduinos.