Understanding state machine example

ChangeState is a function (notice the parentheses after the name). It is not "initialized", it is defined. C and C++ require this definition to be outside the definition of any other functions (such as loop).

This is suspicious:

// Timing variables
int StartTime = 500L;
int ScanTime = 1500L;
int RESULTSTime = 1500L;
int ResetTime = 2000L;

Long int constants are used to initialize (not-long) int variables. It works, but the moment that you try something like:

int ResetTime = 32768L;

you are going to have a problem. 32768L is a legal long int constant but it is not a legitimate value for a (non-long) int variable. I am not sure whether it is going to cause a compiler error message or wrap around to -1, but it is going to be annoying.