MorganS:
I looked for that button library. I found one version which claims to be the latest version for Arduino. It was last updated in 2011. You may have a later version.The button library makes a few beginner mistakes in the code. It also doesn't seem to have any built-in debouncing. You would have to add your own debounce code, which is about as complex as just doing digitalRead() yourself.
Throw away the library. It is holding you back. Learn to use digitalRead(). Learn about debouncing, which is a necessary component for reading mechanical switches.
Now, returning to your actual project, remember that the Arduino is almost infinitely fast. It will be able to take several readings of the input in a millionth of a second. It will be able to detect the button bouncing for many milliseconds. So it needs to ignore those bounces and wait until the button is "really pressed". Then it can do an action.
But that action also takes a millionth of a second. Your finger is still on the button. In fact you are still moving the button down by the time it detects a successful press. So it has to wait until the button comes up. It will run thousands and thousands of times waiting for you. Computers are good at waiting.
So after all of that, you have successfully recognized two changes in "state". The button went down and the button went up. Now it is up to you to take an action when you find those events.
Thank you Thank You!!!!!!!!!
i used delay before the for loop ends and it works
i searched for other method but i will use this for a while though i know it has some issues with reliability because it relies to the delay. and what if the user pressed too long or hold the buttons
but anyway thanks for your insights
BTW i observed that people who practice the use of curly braces are quite old maybe in the not so distant past where programming is a real discipline and where error detection is awful. and i look up to them because for me they are the real programming lords : )