Use a flag to indicate that beep has occurred, clear the flag when the switch is opened to allow beep again.