Greetings, I have the problem with this code that when the sensor variable is activated, the serial monitor stops.
I want to know how I can make the monitor continue showing the humidity measurements.
The programming is made so that every 24 hours the red leds turns on and when the humidity is optimal, the green leds turns on and stays on for 24 hours. While this happens, the serial monitor is supposed to continue working, but it doesn't.
This line will stop the CPU from doing anything for 420000 milliseconds, or about seven minutes.
If you want the CPU to be able to send things to the serial monitor, you need to use the same millis() technique you use elsewhere in your program.
Not a trial, my friend, just an observation. millis() returns a value, it doesn't do the equivalent of delay() so it can't be used in the same way.
Several other points; you're writing to different output pins than you've set as outputs. 8/9 vs 9/10.
Your code is taking a nap for a long time, so of course the display won't be written to.
This if (20 < humidity )
is unnecessary, as you're already in the else clause of if (20 > humidity )
But, what happens if humidity is = 20?
As for your question, read some more about non-blocking code, and figure out how to properly respond to your once-a-day need without taking a 24 hour dirt nap.
This is unreliable, it will fail when millis() rolls over. Please read the millis() documentation and examples to understand why. What you have made, is a future timestamp and you compare millis() against it. What you must do, is store a past time stamp, subtract it from current millis(), and make decisions based on the difference.
All of the example code does that. So I guess you never bothered to look at it. That, or else you believe that a lot of seasoned programmers are wrong.