help
about the button,
i want when i press and hold the button the program inside int execute one, if i want to execute it again i release and press again the button.
thank in advance
Not sure what you want? Do you want some one to do it for you or tell you how to do it.
You need to read the button and hold in a while loop until it is pressed.
Do your thing
Then hold in a while loop until it is unpressed.
Grumpy_Mike:
Not sure what you want? Do you want some one to do it for you or tell you how to do it.You need to read the button and hold in a while loop until it is pressed.
Do your thing
Then hold in a while loop until it is unpressed.
thanks sir for the reply
sir can i have sample code?
my project is a gun sound effect, when i press the trigger it will sound once, until i press it again
packingtape:
thanks sir for the reply
sir can i have sample code?
my project is a gun sound effect, when i press the trigger it will sound once, until i press it again
Look at the Signal Edge Detection example in the Arduino program.
Arrch:
packingtape:
thanks sir for the reply
sir can i have sample code?
my project is a gun sound effect, when i press the trigger it will sound once, until i press it againLook at the Signal Edge Detection example in the Arduino program.
sir this my project..
the problem is when i press and hold the button the sound loop, what i what is when i press and hold the button it will play once..
You have to detect when the button state (well, its pin actually) changes from LOW to HIGH (or viceversa). For this you have to use a prevBtnState variable anche check it against the current reading.
tuxduino:
You have to detect when the button state (well, its pin actually) changes from LOW to HIGH (or viceversa). For this you have to use a prevBtnState variable anche check it against the current reading.
sir can i have example..?
Sure:
That section has several useful example. It's a recommended reading.