Inertial Sensor ( vexcode pro)

Does anyone know how to code the inertial sensor in vexcode pro/ know of any good places to learn how to code it? I have the api, however, I have no clue what values it returns and when and why and I am very confused. For context I am planning to not only use it for P loops for autonomous but also to adjust mecanum lateral movement to be horizontal with no turnage. Any help is appreciated thanks

Go to File->Open Examples. In the pop-up, there’s an example called “Accurate Turns (Inertial Sensor)” which would be a good place to start


You said you have the api, what exactly are you confused about? For turning, the main function you would need would be to find the heading: Intertial.heading(deg)

I don’t believe you can use the inertial for lateral movement - it’s only meant to be used for rotation. Ii suggest using tracking wheels for that

Edit: I misread your post, you meant using the inertial to keep the robot straight while it moves right? In that case then yeah you would only need the heading function for that

1 Like

Yeah I assumed. However, ive tried printing out the heading to the controller and it prints a giant string of numbers with seemingly no correlation to the direction is pointing. I have calibrated the inertial sensor multiple times. Here is my printing code:
double turny=Inertial.heading(deg);
Controller1.Screen.print(“degres: %d”,turny);

not sure if there is somehting wrong with it, but it prints random crap on the screen

Try using %f instead of %d. I’ve found that sometimes using %d (integers) for a double can make the brain print some weird stuff


wait %d is for integers? thats a bruh moment

1 Like

hmm, i tried it and it keeps printing 0.000000. It’s a bit of an improvement from 876536475665 but still not optimal, any other suggestions?

oh wait i just found an inertial sensor priting tutorial on the examples horay