What do you think happens during this:
delay(500);
Nothing. Nada, Zip. Zilch.
And, yet, you do that on EVERY pass through loop(). Why?
Instead, once the switch has become pressed (see the damned state change detection example), you should be making some noise, and then twiddling your thumbs until it is time ti turn the pin on.