LCD "Pages"

Hi there,

I have 4x20 LCD Display on witch i am displaying temperatures, humidity, pressure, and some other stuff, and i am wondering if there is possibility to make a switch to toggle between "pages" on LCD?

i already written some code for it but it isnt working as it should because of lcd.clear() and i dont know how to make it trigger only once when i am flipping the switch

here is the part of the code

void loop{


if (digitalRead(ButtonPin = HIGH))
    {
        lcd.clear();
    displayDataLCD2();
    }
    else
    {
        lcd.clear();
    displayDataLCD1();
    }
}
digitalRead(ButtonPin = HIGH))

Look closely

i know it should be double == but that isnt the point of my question the point is how to make lcd.clear() after changing button state form LOW to HIGH and HIGH to LOW to perform only once.

Look again.

The trick is to remember what state the pin was last time you looked at it.

u mean something like :

int prevState = LOW;

void loop()
{
   int currState = digitalRead(somePin);
   if(currState != prevState)
   {
      // A transition occurred (from pressed to released or from released to pressed)
   }
   prevState = currState;
}