Fr4 photo interrupter for encoding DC motor

I have bought a photo interrupter that has a nice breakout, called the Fr4 by keyestudio on ebay. The encoder works great and the nice LED shows that it's registering input. However, I have searched long and hard for a good introduction on how to make this work in my robotics application.

I have tried interrupts with a count to 20 steps. The output is irregular with it skipping steps and stopping my robot at drastically various distances. My code is simple and barebones; it's the simple interrupt code that I have found in many places with a google search. There has to be a simple explanation. What is a good way to detect the trigger of my encoder? I've been months at this thinking about it all the time and I am so stuck on this. Please help!