Running loop for a specific time period
Your code has a number of problems: 

Don't put #include statements for header files in the middle of your code. They belong at the top, before any other code. (What is the header file elapsedMillis.h?)

Another thing: Your for loop is a mess. It should read something like: for (int i = 0; i &lt; 20; i++) (That would cause the for loop to run 20 times, with the value of i ranging from 0 to 19.) However, what do you want to happen in your for loop? Without braces after that code, the ONLY line that will execute 20 times is the int BPM = BPM + 10; line (which doesn't make any sense.)

You really shouldn't use time-based while loops inside your main loop function. That defeats the purpose of using timers instead of delay statements. And you should get rid of your calls to delay() and use millis() to manage all your timing. Do a search on "Arduino blink no delay" and study the examples for information on how to restructure your code.