To run different loops in same program to display two sensor readings with delay

Here is my problem:

I have two sensors, DHT11 and SW-420, I want them to display readings simultaneously or one after another. I have an LCD, I want the DHT11 sensor to display it's readings first, fade out and then display the vibration amplitude on the same 16x2 LCD. How is that possible?

Please suggest some alternatives to the problem.

Yah, you put both parts in the same loop and use a variable to control which part runs at any time.

 ---- untested pseudocode to show logic only

byte state = 0;

void setup()
{
   ----- whatever
}

void loop()
{
  if ( state == 0 )
  {
      -------- first task

      if ( task is done )
      {
         state = 1;
      }
  }

  if ( state == 1 )
  {
      -------- second task

      if ( task is done )
      {
         state = 0;
      }
  }
}
[code]

Have a look at the demo Several Things at a Time

...R

I don’t think a regular 1602 display can do fading.

A led can be faded and a 1602 can do the same, both are magnitudes faster than the human eye.

When making a project with possibly fast changing data like a speedometer, one of the pains is only showing 4 or 5 different values per second to keep the LCD from blurring.

GoForSmoke:
A led can be faded and a 1602 can do the same, both are magnitudes faster than the human eye.

Technically - sure, it will be possible.
Practically - I don't think the 1602 (or its control IC) has the functionality to do this, and a quick Google search doesn't show anything useful either.

Right. You can display numbers on an LCD so fast they blur together but can't show a value for 5ms then blank for 1ms to 20ms and repeat that?

Fading an LCD seems a bit daft to me but I already know it can done just from fixing LCD blur issues.

I've had all kinds of unwanted effects on the display indeed :slight_smile: Never quite got to something that I would call fading, it was mostly flicker.
This kind of timing may work when connected over the parallel interface. Gonna be tricky to pull off with an I2C port extender, which I always use with these displays.