Giland:
how aboutthe for command works if used in a separate function instead of being inside the void loop().
when the if loop has i in the function reach 5 (no longer less than 5), it will return back to the void loop() and wait for another button press.
No, that is gibberish too. Are you deliberately trying to confuse people?