P-looping with VexCode blocks

Our team is new to vex and we only use VexCode Blocks to program our robot. We would like to add p-loops on our program so that it slows down as it comes nearer to the target position. We use the v5 smart motors internal encoders. So we wrote our program and when we tried to execute it, we noticed that the robot drives a certain distance at a constant speed and then it stops and starts again and stops and it continues like that until we stop the program.
1 2
We would really like to know the problem with this code because the competition is approaching and we still haven’t written our program.
Thanks in advance :slight_smile:

1 Like

Take a look 839 tutorials, it may give you some idea how to code pstraight. It was coded for VEX IQ robots, but the concept is exactly the same. How to make VEX IQ robot drive straight with VEXcode blocks (cautiontape.ca)


Thank you for the link. I still have got some questions. Is it necessary to have a gyro to program a pstraight? Because we don’t have any. Can we still use ploops for our robot?

1 Like

You can use inertial sensor. If you just don’t have any sensors at all, you can compare left and right encoder value, and still be able to go straight with that. In that case error = left encoder value - right encoder value.