Why does serial.read stop working?

PaulS:

void loop(){

EXEC(Hold0);
}



First, all upper case names are reserved, by convention, for constants that are #defined into existence. That is certainly not the case here.

Second, the name tells us NOTHING about what the function does.

Third, it is pointless to have a function that does nothing but call another function. One of them is redundant. It isn't loop().

Fourth, the indenting in the rest of your code sucks. Use Tools + Auto Format BEFORE posting any more code.

Why not throw in "and your mother wears combat boots!" while you are at it, PaulS?

At any rate, I'm merely following the examples set up in the SM library . My apologies that the library's use of EXEC and single functions within loop() offend you. I made the assumption that since a more experienced programmer made the library, I should just follow his/her lead. Merely pointing out defects in my usage without providing possible solutions is not particularly helpful though.

Regarding my indentations, I did an autoformat and found all of 4 diffs between the two files.
Here's the autoformatted output:

#include <SM.h> //Simple State Machine Library
//State Machine names go here MachineName(headstate,bodystate)
SM Hold0(H0h,H0b);
SM Strike(S1);
SM Hold1(H1b);
SM Mash(M1);
//SM Hold2(H2) ;
//SM Boil(B1) ;

/**** global variables *****/
double Setpoint;
//String str;

void setup(){
  Serial.begin(9600);
}

void loop(){
  EXEC(Hold0);
}

State H0h(){
  Serial.println("hello");
}

State H0b(){
  while (Serial.available()>0) {
    String str = Serial.readStringUntil('\n'); 
    if(str == "next"){
      Serial.println("going to Strike");
      EXEC(Strike);
      Hold0.Finish();
    }
  }
}

State S1(){
  Serial.println("S1"); 
  Setpoint = 155;
  int temp = 150; //manual faking of temperature
  while (temp < Setpoint){
    temp++;
    Serial.print(Strike.Statetime());
    Serial.print(" setpoint= ");
    Serial.print(Setpoint);
    Serial.print(" temp= ");
    Serial.println(temp);
  } 
  Serial.println("going to Hold1");
  EXEC(Hold1);
  Strike.Finish();

}

/*State H1h(){
 Serial.println("H1");
 //Hold1.Set(H1b);
 }*/

State H1b(){
  while ((Hold1.Statetime() - 5000000)){
    while (Serial.available()>0) {
      String foo = Serial.readStringUntil('\n'); 
      if(foo == "foo"){
        Serial.println("going to Mash");
        EXEC(Mash);
        Hold1.Finish();
      }
      else if(foo !="foo"){
        Serial.println("HUH?");
      }
    }
  }
  Serial.println("h1b");
}

State M1(){
  Serial.println("Mash");
}

You are correct that my functions have very little description to them -
Hold just means that the code shouldn't do anything until I send an input. This is to give time for adding ingredients or removing ingredients. Strike is the initial heating of the water.
Mash is the conversion of starches to sugars within the grains.
They are different states because the inputs/transitions for each state is different.
Hold just waits for a user's input, in this case the string "next" to come over the serial pipe.
Strike is just looking for temperature to hit its target.
Mash (isn't yet, but will soon) look for temperature to be near target and wait for some period of time.

Robin2,
The reason I chose the SM library is it seemed like an easy way to implement the state machine with some extra timing functions thrown in. Being able to have multiple "machines" running with separate Timeout() functions seems like it would be great if I want to scale up to a 3 pot system (currently, this is for a single pot, Brew-In-A-Bag). I will dig into your thread a bit more though, seems like you understand state machines quite well. I did try switch(case), but found that it doesn't like the switch being based on long strings coming thorough serial. Seems Switch can deal with bytes and integers. If statements seem to produce a lot of code, so I was trying to avoid them, particularly since there may be a variable number of states (Mash steps could be between 1 and 4, usually 1 or 2 steps).

Thanks,
JR