Encoders coding help

Hello, I was seeing that to obtain the position of the encoder “encoder Get” is used but this is in pros, if you could give me an example of how to do it in another way it would be amazing! Thank you.

void moveDistance(int tick){
        int distTravelled = 0;
        while(distTravelled < tick){
                // set motor power to max
                distTravelled = encoder.get(); // updates encoder distance travelled
        }
}
3 Likes

I just pasted this in my code, but I have an error in “get” how can I solve it?

apparently I succeeded using this code snippet

float distTravelled = Encoderleft.value();

Thank you!

2 Likes

Yep, that is the correct function. For issues like this, my go to is the vexcode API page which is at https://api.vexcode.cloud/v5/html/index.html. it’s a life saver for me.

5 Likes