Activation system with DS18B20

Hello everyone!

I'm new to Arduino and I'm confronting a project that I can't wrap my head around.

I programmed two light behavior (with addressable LEDs and FastLED library) that I want to have as turning-on and turning-off animation for my system and I included them in a switch/case and serial.read to the simplicity of testing them. the main code looks like this:

void loop() {
  // this code is only for testing the animations
  if (Serial.available() > 0) {
    int inByte = Serial.read();
    
    switch (inByte) {
      case '1':
        turningOn(2); // number of times it breathes
        Serial.println("you pressed 1! Activation");
        delay(10);
        break;
      case '2':
        turningOff(1); // number of times it breathes
        Serial.println("you pressed 2! Deactivation");
        break;
        delay(10);
    }
  }
  turningOn(0);   // Just run it continuously.
  turningOff(0);  // Just run it continuously.

  FastLED.show();

}

Now... instead of the serial.read I want these animations to be triggered by a temperature sensor, specifically a DS18B20. I'll try to explain what I would like to do:

The DS18B20, mounted under a thin metal plate, needs to sense a heat change and not just a specific temperature.
It should sense if the temperature increases e.g. 5 degrees over a 30/60'' or so but not if the room temperature changes throughout the day.
If this happens, it should tell the system that is ACTIVE, display the turningOn() animation, and then allow other things that I want my system to do.
When the system is ACTIVE and the opposite happens — the temperature decreases 5 degrees over a 30/60'' — the system should display the turningOff() animation and shut down every process, except the temperature reading, for future activations.

Since this is fairly complex, I'm struggling to understand the logic my code should follow. I could really need some help here.

Thanks in advance for any answers.

This project may be helpful for you: Arduino - Cooling System using DS18B20 Temperature Sensor

IoT_hobbyist:
This project may be helpful for you: Arduino - Cooling System using DS18B20 Temperature Sensor

Thanks, I'll check it out!