Speed control of dc motor using bluetooth. Speed is constant even loaded

Hello…I am doing a project. Aim is that the inputspeed is sent from Bluetooth. And the motor will rotate at the same speed even loaded…I am calculating the motor rpm by using interrupts. The program will interrupted for every rotation. According to the time between two interrupts the motor speed will calculated…And I am comparing the motor speed with the inputspeed and increasing the pwm accordingly… But I am facing some problems in my project. When there is no interrupt my program is interrupting automatically and shows motorspeed to 9998. I am thinking that my Bluetoothmodule may messing with the interrupt program. Please help me to find solution. If you don’t understand my problem. Please ask me. I’ll try to explain it better. My basic structure program is attached to this topic. I am skipping serial prints in my program

project program.txt (674 Bytes)

I'm going to guess that pin two is floating.