Artificial intelligent assistant

Counting blinks of a LED I'm working on an algorithm that counts blinks of a LED. I have series of non-neagtive integers. They represent brightness of a LED in time. I give you two examples of these integer series below. Visually it's very obvious that LED blinked 7 times in example 1 and 8 times in example 2. But how can this be calculated by a computer. Any ideas? I don't even know if I'm asking this question on the right site. I'm new to this stuff but any help would be appreaciated. Example 1 Data of Example 1 ![enter image description here]( Example 2 Data of Example 2![enter image description here](

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.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e59d93ef212cb78d06896b81d73d81fe