Count analogRead

Hi, I have a Serialoutput from a analogRead signal and i want that if the number 0 poped up 10 times, it should do something.

Like this:

 If ((10*)a == 0){
             doSomething}

My Serial output is:
100
95
91
80
61
47
26
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
30
53
75
93
110
115
114
113
111
105

And if 0(red) poped up 10 times it should do something.
Thanks for your help :slight_smile:

you need to have a counter in your code. When you read the analog value, if it zero increment the counter. If it is not zero, set the counter back to 0.

Then, check the counter and if it is 10, do something (and possibly set it back to zero).

Give it a try. Write some code. If you get stuck, post your code and ask for help

Okay, thanks, I'll try. :slight_smile: