Question: No matter how I rearrange this, the increment compare always returns false....

I have even taken it out of the if, and put it in its own if:

```
int buttonFSM(button *ptrButton)
{ 
    int i;
    i = digitalRead(ptrButton->pin); 
    switch(ptrButton->buttonState)
    {
    case SW_UP:
        if(i==0 && ++ptrButton->debounceTics == DBNC_TICS) //swtich went down
        {
            ptrButton->buttonState = SW_DOWN;
            ptrButton->debounceTics = 0;
            return SW_TRANS_UD;       
        }
        ptrButton->debounceTics = 0;
        return SW_UP;
    case SW_DOWN:
        if(i==1 && ++ptrButton->debounceTics == DBNC_TICS) //switch is back up
        {
            ptrButton->buttonState = SW_UP;
            ptrButton->debounceTics = 0;
            return SW_TRANS_DU;       
        }
        ptrButton->debounceTics = 0;
        return SW_DOWN;   
    }
}

```

Answer: 
Looks to me like the path where the if doesn't happen are getting you. You don't show what DBNC\_TICS is set to, but I'm assuming it's > 1.

ptrButton->debounceTics will never be greater than 1 because you always:

```
    ptrButton->debounceTics = 0;

```
```C++
  if(i==0 && ++ptrButton->debounceTics == DBNC_TICS) //swtich went down
    {
        ptrButton->buttonState = SW_DOWN;
        ptrButton->debounceTics = 0;
        return SW_TRANS_UD;       
    }
    ptrButton->debounceTics = 0;

```

I'm going to agree with user3877595 but explain why, as his/her answer got a downvote.

`DBNC_TICS` has to be > 1, right? Otherwise what is the point?

We want to debounce after "x" ticks, and let's assume that the number of ticks is initially zero.

If `DBNC_TICS` is == 1 then this is always true:

```C++
++ptrButton->debounceTics == DBNC_TICS

```

Therefore that test is useless.

If `DBNC_TICS` > 1 then it will not execute the "if" block and execute this instead:

```C++
    ptrButton->debounceTics = 0;

```

So `ptrButton->debounceTics` is back to zero, and we are back to square 1.

Therefore the test will always be false.

> 
> No matter how I rearrange this, the increment compare always returns false....
> 
> 
> 

As stated in the question.