Vex catapult rotation sensor code

so i’ve been trying to code my rotation sensor for vex over under and it won’t work…
I have my code written as

From the looks of it you may need to define a variable and assign it to Rotation17.angle. Then use that variable in place of rotation17.angle.

int rotation17angle = Rotation17.angle;

if ((rotation17angle  >  55)  && ( rotation17angle < 350)) {
     catapult.stop(hold);

// and then add the L1 button code here. 

Note: This needs to be in a loop. Also, I am not entirely sure what you are trying to do here, as rotation17angle would need to be two values at once, at least based on my interpretation of your code and it’s idea.

yea, almost, you all need to study the C++ language a little more.

A correct use of angle in a conditional statement would be

// if the angle of the rotation sensor is in the range 55 to 350 degrees
if( (Rotation17.angle() > 55) && (Rotation17.angle() < 350) ) {
  // add code here
}

and assigning to a variable (although angle() returns a double, this would still be ok)

int rotation17angle = Rotation17.angle();
8 Likes

If you are running a limit switch, you can use this code. In this case, I just use it for a bumper sensor.

Oh my gosh how did I even realize my mistake. Yes it would need ().
It’s been too long of a week. Sorry about that.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.