Arduino Lighthouse

Do you have a pull down resistor connected from the switch input to ground?

Please provide a better description of what the sketch does.

Add serial prints to the code so you can follow execution and see where it is getting stuck.

Please read the "how to use this forum-please read" stickies to see how to post your code.