Need assistance helping my programming student

I’m a relatively new robotics coach with little programming experience and I need some help assisting a student of mine with his code. Honestly, he is much more capable of coding in Vexcode Pro V5 Text-Based Coding than I am, but he has hit a roadblock.

Details about his bot/code: He is working with a standard clawbot and he has added a vex v5 inertial sensor to the drivetrain. He has successfully worked with the sensor already. Currently, he is working on programming the controller. The code he is currently working on is supposed to get the robot to turn 90 degrees upon pressing the “A” button, raise the class upon pressing the “UP” button, and lower the claw upon pressing the “DOWN” button. The last two functions are working properly, but whenever he presses the “A” button, the robot spins indefinitely.

Here is the code he wrote:

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!


Drivetrain.turnFor(right, 90, degrees, 50, velocityUnits::pct);


armMotor.spinFor(forward, 90,degrees,50,velocityUnits::pct);





Again, I’ll be honest in stating that he is much more advanced at writing the code than I am (and as a 6th grader at that!). He is also using a Drivetrain.turnFor code, which I am unfamiliar with. When I went to the Robotics training at Carnegie Mellon (3 years ago - and most of that knowledge has faded a bit due to the pandemic), we were coding the drivetrain as individual left and right motors. I thought that might be part of the issue, and recommended he try that route, but he said that would interfere with the internial sensor in some way.

Any assistance at all you can give us in the matter would be greatly appreciated. Thank you in advance!

Make sure the inertial sensor is configured in the drivetrain in motor and sensor setup.

I’ll have him look into that. Would that be causing the drivetrain to spin indefinitely rather than 90 degrees?

If the inertial sensor isn’t configured with the drivetrain it will continue to wait for a reading from the inertial sensor that it will never get.

Here in drivetrain settings you need to add the inertial sensor.


I believe he has done this already. I took a look at the motor configuration and this is what I found:

Does the robot stop if the button is let go?

Is it possible the inertial sensor is configured upside-down or backwards of how it really is? Try selecting no gyro and see if it works. And then if it works, try taking the inertial sensor and flipping it upside-down. Or try re-configuring the inertial sensor (I think) to represent which way is up. Or try printing to the brain the various outputs of the inertial sensor.


It does not, just moves indefinitely after 1 button press and immediate release.

I’ll have him give that a shot.

You should put him in here. It’d be much easier to talk to him then talk to him through you.

I proposed that, but he was resistant to joining the forum. He is only is 6th grade, so I didn’t really push him. I told him I would try to figure it out, but after trying a couple things I’m still at a loss.

So from what I am understanding you guys are trying to use the inertial sensor to turn. What I do when using the inertial sensor is I configure it separate from the drivetrain and do a
{repeat until inertial_1 <(desired angle) & inertial_1 > (desired angle)}
and this gets it to turn perfectly every time for me.


Is the robot turning clockwise ? (to the right) If it is turning counter-clockwise then drivetrain motors are configured incorrectly.


It is turning clockwise (to the right).

That sounds like it could be it. I’ll have it give it a shot.

1 Like

Also for the
{repeat until inertial_1 <(desired angle) & inertial_1 > (desired angle)}
Say if you wanted to turn to 90˚ do
{repeat until inertial_1 <(91) & inertial_1 > (89)}
And that will work.


Thank you for all the tips! I’m going to pass these along to him at our next meeting.

1 Like