With the data you show it is easy. Find the maximum brightness, divide by $2$, and call the LED on when the brightness is above threshold and off when below. Then look for how many runs of on you have. You have an LED that has consistent on and off times and no noise spikes, which is what makes it easy.
Issues may come when you get one stray reading. Maybe somebody shines a flashlight into your sensor for a moment. You might get a high reading for one sample, which the above would call another pulse. You can plot the on times and notice they are consistent except for this one pulse and decide to ignore it. You are essentially modeling the behavior of the LED and ignoring data that doesn't fit the model. It gets much harder.