I believe @Robin2 meant for you to move the line:
int lastAnalogValue = 0;
To the top of program and delete it from where it was (line 21 now).
I believe @Robin2 meant for you to move the line:
int lastAnalogValue = 0;
To the top of program and delete it from where it was (line 21 now).