@hsn6827: I'd first get rid of the unnecessary threading. Since you're only using one thread, threading is only adding overhead, with no benefit. Instead, make use of the timer library, setup a periodic timer, & count RPM from there. Or, better yet, use the frequency measurement capability...