I still cannot figure out what I have done wrong.
Well, for one thing, you've posted code incorrectly twice now. Use the icon with the # BEFORE pasting the code.
Do you, or do you not, have something connected to digital pin 1? If so, you can't use Serial in the sketch AND having the thing connected can interfere with uploading code. If not, why are you, in the first sketch, diddling with pin 1?