State machine comparision

as quick feedback on this

// the possible states of the state-machine
typedef enum {
   STATE_BEGIN_INPUT,
   STATE_GETTING_ROTATION, 
   STATE_GETTING_SPEED, 
   STATE_OUTPUT_RS} states;
  • typedef is no longer needed.
  • by default enum entries are stored using an int, which is two bytes. As you have very few and you don't care what value they hold, I would suggest to define them as byte
  • semantically your states variable only represent one state. so better practice to call that state or currentState for example

so would write this such

enum : byte { 	
   STATE_BEGIN_INPUT,
   STATE_GETTING_ROTATION, 
   STATE_GETTING_SPEED, 
   STATE_OUTPUT_RS} state;