# Discrete value change using Whenevent function with differential equations?

GROUPS:
 Hello there, I want the discrete value of "a" to change every time the velocity reverses from positive to negative for example: when the velocity becomes negative I add 1 to the variable "a" and it accumulates for that value when it happens again for example: the first time the velocity becomes negative originally a=1 but when becomes negative i add 1 to it so it becomes a=2 then suppose it happens again to be negative then a=2 so i add 1 to it so it become a=3 and so on a=1; Sol=NDSolve[{x''[t]+(a+1)Sin[x[t]]==0,x[0]==1,x'[0]==0.5,WhenEvent[x'[t]<1,a->a+1]},{x[t],x'[t],a},{t,0,10}] Plot[x'[t]/.Sol,{t,0,11}] Table[Flatten[{t,x'[t],a}/.Sol],{t,0,10,0.5}]