So at our competition our teacher gave us an idea. He said “Hey, you guys know you can stop the motor from going after a certain degrees with encoder code right?”. Turns out he didn’t remember it and we haven’t been able to figure out how to do it cause we’ve never used encoders before.
We’re using vexcode V5 text so if anyone can help we’d really appreciate it.
Well, you can use the internal motor encoder with commands like rotateTo and others. The internal encoder is already in each V5 motor. Hence, you can use the .position( rotationUnits ) command to get the motor position.
Here is a thread discussing using the internal encoders
I know what you mean since I’ve been looking for a while, but I don’t think that’s it. For example say we’re testing the Pivot, we don’t want it to rotate and then stop like the RotateTo command does. What we want is for it to automatically stop after it rotates a certain degrees, not allowing it to go beyond that but letting it go back down. Like if you were using the joystick for the pivot motor, you’d push it up but it would automatically stop after whatever degrees to stop you from messing up, but still letting the driver take it back down. Is there anything like this?
A google image told my comrade that this code was the way to go.
while(Motor.rotation(rotationUnits::deg) > Number of degrees)
Turns out this works just fine. Posting it so others who want to use it can without having to go through the hellscape that was searching for it.
Thanks to all of you for helping us!!
Is it possible to have someone explain of how to use the encoders effectively. Can’t work on coding if I don’t understand where to put it and what to code it as when in a competition template, and if you could, explain in v5 text, not ROBOTC.