How to add constraints on states in ODE's using NDSolve?

Hi,
Simplifying my question is that assume an ODE such as

x'[t] = Sin[x[t]]

constrained to:

x[t] = Max[x[t],0.5]

How can I implement this constraint and solve the ODE using NDSolve?
Thanks.

You can use WhenEvent for things like this:

Thanks, that’s exactly what I was looking for.

ok, now I am confused.. going back to my example, lets assume this problem: we have a simple x’ = sin(2.pi.t) and we want to make sure that x[t] values do not exceed 0.1 (i.e., trimmed at 0.1). The following script does not work, any idea?

NDSolve[{x'[t] == Sin[2*Pi*t], x[0] == 0, WhenEvent[x[t] > 0.1, x[t] -> 0.1]}, x, {t, 0, 1}];
Plot[x[t] /. %, {t, 0, 1}, AspectRatio -> Automatic]

Found the answer. I will use Piecewise function in the definition of the derivative.