Create a counter variable. Increment it each time the switch changes from not pressed to pressed. When the counter gets to 3 reset it to 0. Your three states are 0, 1, 2. When counter == 0 enable whatever code you need for that state - like maybe lamp off? When counter == 1enable code for flashing, and so on.