Counting blinks of a LED
You can do something like this in Python (setting data to your original signals):

import numpy as np
data = data1

max_val = np.max(data)
thresh = max_val/2
thresh_crossings = np.where(np.diff(np.signbit(np.array(data) - max_val/2)))[0]
print(len(thresh_crossings)/2)


This code returns 7 for your first signal and 8 for the second one.

First I find the maximum value. Then I arbitrarily set a threshold (in this case, half that value), taking advantage of the fact that the signals are pretty clean and there are not any spurious peaks. Doing so leads to something like this:



Then you just have to find how many times the signal crosses that threshold, and divide it by two (because it will cross it twice for each peak, once when it rises and afterwards when it falls).

If you have any additional information a priori of the frequency of the peaks, you could add some hysteresis to make the algorithm more robust (i.e. if there are small zigzags in the signal, avoid counting them as threshold crossings).