Ali, you say that the shaft is static and the bearings are moving; and I'm guessing you want your sensor to be static w.r.t. the shaft? (i.e., as the bearings spin, the sensor and its signal wires don't spin with them). Anyway, you are only counting full revolutions which makes things easy. You can adapt Milind's idea to your situation by shining a laser at the bearings rather than at the shaft. Or, you can use an opto-interrupter. Another alternative is to use a hall effect sensor. There are many methods you can use, and the decision boils down to what application it is being used for.
- - - Updated - - -
Ali, you say that the shaft is static and the bearings are moving; and I'm guessing you want your sensor to be static w.r.t. the shaft? (i.e., as the bearings spin, the sensor and its signal wires don't spin with them). Anyway, you are only counting full revolutions which makes things easy. You can adapt Milind's idea to your situation by shining a laser at the bearings rather than at the shaft. Or, you can use an opto-interrupter. Another alternative is to use a hall effect sensor. There are many methods you can use, and the decision boils down to what application it is being used for.