Flickering LED

As a matter of interest, do you have the button connected with a resistor to pull it the other way when it's not pressed, like shown here or is it floating?

You might also find it useful in problems like this to adopt the approach shown co-incidentally in the link of using Serial to print various things back to the monitor on your PC so that you can see where in the code it really is at any instant, and what the values of variables are.