Encoder Autonomous not working

I am trying to program (VCS) an autonomous that is based on sensors. I am using the integrated encoders in the V5 smart motors. (I’ve taking out the vital part and put it in a new code, so ignore that it is running in the main bracket. I have checked in which direction the encoder value goes (it goes up):

#include "robot-config.h"

int main() {
    while(DL.rotation(vex::rotationUnits::deg) < 360){}

However, it doesn’t seem to be working. The robot just keeps on driving forwards. I am pretty sure my code is at fault since I am basing it off of the way I used to do it on robotc. I have also tried to diagnose the problem by displaying the encoder values on the brain screen, and it works fine. Any help on what I need to change would be appreciated.

On v5 there is an easier way to do this
I would recommend you look at the api here http://help.vexcodingstudio.com/#cpp/namespacevex/classvex_1_1motor/rotateFor.

This should be


Thank you for your reply. I will test out the new code next time I have a chance to.

I tried the code and it works! I have another question: How do I make the motors turn backwards? It seems everything that I try doesn’t work.

Switch to negative targets instead of those positive 360s.