rotary encoder does not work when pulseIn active

Robin2:
Also, what is the role of the rotary encoder?

As I wrote the Rotary Encoder using to increase and decrease the value which sets the speed of Fan

Robin2:
I suspect it would be useful to use the digitalWriteFast() library.

Could you please clarify the function of particular library?
The problem is with reading the frequency of RPM, not driving of Fan