Turn motor 90 degrees on controller button

My team wants the robot to turn 90 degrees when button E Up is pressed. We have been unable to find the combination of blocks to accomplish spinning the right motor for a defined amount of rotations on pressing this button once. Can someone please help!

Thanks!

You can accomplish this very simply with a gyro. The gyroscope can track the angle/position of your robot, and using VexCodeIq, you can really easily accomplish this.

All you need to do is:
When button E Up is pressed:
Turn to rotation 90 degrees

When mounting the gyro, make sure that it is facing up, or it will be unable to track properly.

Good luck! If this doesn’t work for some reason, you can reply to this message for me to get a notification!

1 Like

Thanks- without the Gyro, we have tried when button E Up pressed, spin Right Motor for 90 degrees with no luck.

yeah, its hard for the program to know that it is actually spinning 90 degrees if there is no way for it to actually keep track of it

The IQ motors have encoders in them. In modkit and other programs pre-VexCode, we were able to have motors turn without a gyro, so this is possible. However, IQ code overall seems more difficult when programming the controller.

1 Like

It sounds like what you are telling the robot to do is “spin the right drive motor 90 degrees”. This will not result in the robot turning 90 degrees, unless you just happened to design a robot with exactly the right drivetrain dimensions and layout for that to be true (which is very unlikely).

If you want to turn the robot programmatically, you should configure a drivetrain in VEXcode IQ blocks. Tell the configurator which ports the drive motors are connected to (if you have the motors configured separately, remove them first) and uncheck the “gyro” checkbox to get to this screen:

Screen Shot 2020-11-01 at 9.15.05 PM

Enter the right measurements for your robot. If you click the question marks, there are illustrations to show how to measure wheel base and wheel track. If you built the “standard drive base”, “autopilot”, or “clawbot IQ”, or maybe some of the other prebuilds, the default values are already correct, no need to measure anything.

Once you’ve configured a drivetrain, you can use this block:

Screen Shot 2020-11-01 at 9.19.01 PM

VEXcode will do the math based on the measurements you entered to figure out how far the drive wheels will have to spin for the robot to turn 90 degrees.

If you have a gyro, leave the box checked and add it to the drivetrain instead of entering the drivetrain measurements. Then VEXcode will use the gyro to measure how far the robot turns and stop at 90 degrees, which will result in more accurate turns.

4 Likes

Thanks, I do realize that a motor turning 90 degrees doesn’t make the robot turn 90 degrees. But now nothing happens when the button is pressed.

So let me ask my question differently. I want a motor to turn a defined number of degrees/rotations, etc when I press a button on the remote. How do i accomplish this?

This block should do what you’re looking for:

Screen Shot 2020-11-01 at 9.32.23 PM

3 Likes

One would think…but no!

Can you post your code. Using that combination of blocks should work…