Echo the above.
Also suggest:
Using an "enum" type to give each state a name like "waitingForGap" rather than a non-intuitive number like 3. Use this new type to make your "inProcess" variable, instead of making it an int. Another variable, perhaps called "previousProcess" could be updated at the end of loop() so that it's easy to see when the state has changed since the previous execution of loop(), so that any actions that need to be done when entering the new state can be triggered.
When a variable like "coderActive" only ever has 2 values: 0 or 1, use a "bool" variable instead of an int. "bool" variables can only have 2 values: true or false. This makes code a little more readable because instead of saying if (coderActive == 1) you can simply say if (coderActive). When using bool variables, always give them names that reflect the meaning of the variable when the value is true. "coderActive" is a good example. But "onOff" would not be such a good example because it's not 100% obvious that true is meant to mean on and false means off. "systemOn" would be a better name.