Telling which way a KY-040 Rotary Encoder has been turned
probably the 2 outputs have a quarter pulse lenght shift. Use one output as the known amount rotation indicator (=every rising edge means a known angle increment) and the other is the direction; checked when the angle increment occurs. 

Your led flashing circuit:



ADDENDUM: The fi2 output of the rotation sensor states how long the led light pulse is ON. Of course you might want to limit that in case the rotation stops just when fi2=High. For that you can add a monostable multivibrator between fi2 and the nand gates to limit the on-state lenght.