Run state machine if condition met

In that case you need to place the sensor reading also in the in the stopped state and your basically are back where you started :wink:

PS
If we're talking about full code, we mean full code :wink: Not a part of loop but everything:
variable declarations and the likes
setup()
loop()
any functions that you wrote

If it's too big, attach it or spread it over two posts.