I usually put that first thing after "if (buttonState != lastButtonState) {" because at that point you no longer need the old value and if the comparison is false (they are equal) there is no need to change lastButtonState.
I usually put that first thing after "if (buttonState != lastButtonState) {" because at that point you no longer need the old value and if the comparison is false (they are equal) there is no need to change lastButtonState.