You need to save the current state to last state each time through loop() before you read it again so that your program can detect when it has changed.
You need to save the current state to last state each time through loop() before you read it again so that your program can detect when it has changed.