We need a more detailed report of how it behaves. I can tell you at least, that code like this:
if (resultCM ==4){
counter2=0;
counter3=0;
counter1=counter1+1;
if (counter1==1){
is difficult to analyze, and so needs inline comments so the reader can understand.
It seems like you are using three counters as some kind of bizarre debounce or change of state detection system. I think the unnecessary complexity of that system is hiding the main issue (which was already mentioned above), which is that you are detecting the thresholds themselves, rather than a condition of exceeding a threshold which is the normal way to treat a threshold.
Exceeding a threshold is detected with greater than, less than like:
if (resultCM < 4){
There are several ways of implementing a change of state detection system, that are waaaaayyyyy simpler than what you made. The basic logic is;
if (the new measurement is not the same as a saved measurement)
{
save the new measurement to the saved measurement
respond to the change
}
This can easily be adapted to consider inequality like < and >.