Not sure if this can be done but I am trying.

I am working on a project that uses a LCD, Thermisistor, 8 leds with shift register, and serial monitor inputs. The gist of it is within a certain temperature range the leds will light but before this happens the serial monitor asks if you want the temp in C, F, K, or x(clear). The problem I am running into is that I am unable to keep the temperature fluctuation and still use the serial monitor. For example the way I have it right now I am able to switch between C, F, K, or x without issues but the temperature is static to what the reading was before the ‘if’ statements. When I add a while or for loop the temperature reading is dynamic and my project works until I try switching it between the other readings. Perhaps I am approaching this wrong but I am hoping someone can help me.

Please ignore the dc motor I am having no problems with that and I have things commented out just in case I want to try and incorporate it later before the final build. Thank you.

Final_Project.ino (8.16 KB)

Your sketch only calculates the temperature when a character is read.

You should un-comment the part at the top of loop() where it calculates the temperature in F, C, and K.
THEN display the temperature on the LCD according to the current 'mode'.
THEN set the LEDs based on temperature. There is no need for separate K, F, and C ranges. Just use whatever you use locally.
THEN look at the serial input to see if the 'mode' is being set.

This should eliminate a lot of repeated code in the KFC cases.

I wanted to have C,F, and K separate for this project since I will be presenting it for a grade. Sounds like it will be a bit too ambitious at this point. I do appreciate the response I will look into what you described.

If you want to calculate the temperature ranges in each format separately it would be good to have a table of temperatures rather than duplicating a bunch of code:

enum Scales {Centigrade, Farenheit, Kelvin, None} SelectedScale = Centigrade;
// Min Room Temperature, Max Room Temperature, Min Hot temperature
int Temperatures[3][3] = {
{25, 27, 32}, // Centigrade
{76, 80, 90},  // Farenheit
{297, 300, 305}, // Kelvin
};

Use the SelectedScale to keep track of which scale was last selected.

  if (Serial.available())
  {
    char ch = Serial.read();
    switch (ch)
    {
    case '1': SelectedScale = Centigrade; break;
    case '2': SelectedScale = Farenheit; break;
    case '3': SelectedScale = Kelvin; break;
    case 'x': SelectedScale = None; break;
    }
  }

Will doing it this way allow the temperature readings to be dynamic? The main problem I am running into is the temperature will only display the last temperature before entering the case statement. If I use a 'while' or 'for' loop I am unable to use the serial monitor to cancel or move to a different scale. I really appreciate the help I honestly didn't think this would be difficult.

Robin2’s serial input basics might just be what you're looking for. It illustrates non-blocking ways of getting data from the serial monitor.

PaulMC:
Will doing it this way allow the temperature readings to be dynamic?

Yes.