Your timer is running free and will generate an interrupt where you reset some variables. This can invalidate your wanted flow of program.
More: As a general rule: Every global variable (those declared outside of a function) that are changed within an interrupt handler must have the "volatile" attribute!!! This will not yet change program behave, but when compiler optimization is turned on it will!!
memset(arr, 0, strlen(arr)); //way to avoid that symbol and store correct data in array
Why strlen and not the size of the array, this might go wrong under some circumstances.
Increase the size of arr to prevent overwriting of variables in case of bad transmission ('\003' not seen)
Consider declaring global "ind" variable as local static and care for never overflowing buffer sizes.
Thanks, but how I should use timer and interrupt handler function in that case correctly. And another question, it is possible to make few interrupt handler functions that work with one interrupt block?
is it possible to make few interrupt handler functions that work with one interrupt block?
No need to. You can put the code of all handlers into one function or call each of the required sub-functions from the (one and only) handler.
how I should use timer and interrupt handler function in that case correctly?
Imagine what you want: From a certain point on you will allow for one second to get all your information transmitted.
So you will have to stop your timer, re-load with zero (when you count up) and start the timer. When transmission is done, you stop the timer. When the timer runs out you have to stop it, too and set a global (volatile!) flag to show the situation.
Firstly my aim was to start timer after key is accepted or declined, count to 5 sec and close door(change accepted flag to opposite) what means that now it is possible to collect new data to our array and check it again. And my problem is in setting that limit for receiving data after I compared keys. I know how to make it just if correct key was found - replace if(!compared) with if(!accepted).