I think a reset will have the same effect as an upload.
Your val variable is initialised with 0.
The first time you press the button, the if condition evaluates to true and val be be set 1 and after that the if condition will never evaluate to true so no space will be send.