Flickering LED

Thanks for your help guys!

JimboZA, I do have a resistor connected to the button. Your advice about using Serial is definitely something I'm going to start doing! I hadn't gotten to the point in the tutorial where they introduced me to that yet, but I evidently already need it!

LarryD, thanks so much. I puzzled over this for a few minutes and I think I sort of understand why it's doing this.

Am I understanding things correctly if I say that with the analogWrite function, if I do analogWrite(LEDPin, 256), that is the same thing as analogWrite(LEDPin, 0)?

I still do not quite understand why the LED blinks. In particular, I understand that when I run through my while loops, the one with y++ leaves me with a final value of 256 (one more than 255) if I keep holding it and the while loop with y-- has a final value of -1 if I leave the button unpressed for long enough. The thing I'm puzzled about is why does this flickering happen the very first time that I press the button? I would have thought that since I set y=0 at the very start, that at least the first time, the loop would start with a value of y=0 and not a value of y=-1

HazardsMind, I think I understand what you're saying, and the thought had briefly flickered through my mind when I was thinking of another mini-project I wanted to work on. If I understand you correctly, you are saying that I can ditch my two while loops. Does that sound right?

Thanks for the help everyone!