Merging arduino code
In the bluetooth loop you use:

delay(20000);
while (0);


This means you first wait 20 seconds, and while(0) does not do anything (unuseful instruction).

Actually, this results when the button is pressed, it starts the loop again, but you have to merge both codes into one.

I would add the sending of the serial command in the code above, remove the while and see what happens. If you need some delay for debouncing reaons for the button, implement a decent deboucing algorithm instead of the delay of 20000.

And why there are two }} at the end?