Hello
I´ve made a low level flight about the sketch and I ´ve found 16 times a call of the delay() function.
Line 45: delay(2000); // wait for 2 secs
Line 49: delay(100);
Line 51: delay(100);
Line 62: delay(40);
Line 66: delay(100);
Line 68: delay(300);
Line 70: delay(200);
Line 73: delay(300);
Line 75: delay(300);
Line 123: delay(10);
Line 131: delay(10);
Line 135: delay(70);
Line 147: delay(2000);
Line 150: delay(100);
Line 158: delay(2000);
Line 161: delay(100);
The delay() function isn´t delaying it is stopping the processing.
Lay back and think about it.
Have nice day and enjoy coding in C++.