Hello, I am new to arduino, and coding.
I am developing a sort of laser tag. And I have a speaker that plays a sound effect when a button is pressed. But, as of right now, the speaker continues to play while the button is pressed. This is all happening in the void loop. Is there a way that I can get the speaker to stop playing until the button is pressed again?
I want the speaker to play for 250 milliseconds after the button is initially pressed, then stop. Then once the bed is pressed again repeat. This is so if someone holds the button, the speaker does not continue to play.
Any ideas would be greatly appreciated.