How to detect the direction of rotation with a sensor encoder timing disk (photoelectric speed sensor)? I am making a DIY gaming steering wheel and am stuck.
For measuring the rotation of the wheel, I'm using a sensor encoder timing disk, which is usually found in printers. - https://robu.in/product/photoelectric-speed-sensor-encoder-coded-disc-code-wheel.

A lot of tutorials on youtube use this.
But I just cannot seem to understand how to use this sensor.

Please help me in figuring this out: using this sensor, how to -


Measure how much the wheel rotated?
Know which direction did the wheel rotates in (clockwise, anti-clockwise).


PS: I tried using a rotatory encoder, but it is unable to sense rotation when rotated by a 1000 RPM motor. Would love to understand why.

Thanks!
It seems to be a A/B coding : if A gets high before B, it's one way (count for exemple), and if B gets high before A, it's other way (decount).
So, connect power and ground. Then connect the two wires to input pins :

    int P_A=2; int P_B=3; //Inputs
    long int position = 0; //Position of wheel
    long int lastPosition = 0; //last position of wheel : for speed computing


Notice that one pin must be an hardware interrupt pin (Uno 2 an 3 are interrupt pins. Then attach interrupt in the stup :

    attachInterrupt(2, wheel, RISING);  //wheel is arbitray


Then create the interruption code :

    void wheel(){
        int sB = digitalRead(P_B);
        if (sA == sB)   { //Clockwise
        position++;
        }
        else   { //Counterclockwise
        position--;
        }


Then, in your loop, you can print position when it changes to read current position :

    if(lastPosition != position){
        Serial.println(position);
    }


i hope it will help...
Notice that if you use both interruptions, you get a better resolution, but speed limit is lower.