Opto encoder direction using a single wire input

Hello. New here.
I have an opto encoder on a brushed motor on an interrupt on a mega and h bridge. All works as it should.
I'd like to try to work out the motor direction. I realise my opto encoder isn't suited for this purpose, But I'd like to try something...
I have printed a wheel as in the image.
Do you guys think it is possible to work out the motor direction using the spaced holes?

image

I think it will work fine, for reference do some research on missing tooth, this is common in the automotive world as a position sensor.

Thank you. It does work fine. But do you think Its possible to code in to get the direction of spin? Cw or ccw?

I would think so. The pattern of teeth and gaps will be determined by the direction of rotation.

1>gap>2>gap>3>big gap will be ccw

3>gap>2>gap>1>big gap will be cw.

Thinking of how to code for this is making my head spin both ccw and cw.

Nice. I need to think then. The fun part. As long as its possible :+1:

Should not be a problem After the delay do you get three consecutive pulses or 1 space and two.

Look at this image, it is for quadrature detection.


Pick any edge of either sensor and see what level the other sensor is at at that edge. Hint if you use pin B and rising edge, Pin A will be high for Clockwise and low for counter wise. Using the edge interrupt on an Arduino and any other pin you can calculate speed and direction.
Here is a simple circuit for you:
image

Note the Flip Flop does the direction decoding for you, that is what I did in software using an interrupt. You can divide the output to cut processor overhead if you want.