Optical Shaft Encoder Programming Help

Here’s a topic you could read which might help you:

What you’re asking for is generally know as odometry. It’s present in FRC and VRC, you can look for others code and adapt it.