Need help with loop time/interrupt programming

You can simplify; all the global variables are zeroed before setup runs, and T1 and T2 could be initialised when declared.