0
$\begingroup$

I'm trying to create a function that allows me to more easily start a motor, but I'm running into a problem, I don't know the type to use for the motorName argument. I'm using a VEX 269 Motor. Here's the function.

void runMotor(MotorTypeHere motorName, int speed, int time)
{
  startMotor(motorName, speed);
  wait(time);
}

I just don't know what type to put for the motorName argument. What type would it be?

$\endgroup$
  • 1
    $\begingroup$ I am pretty sure it is a string, try that. $\endgroup$ – Mark Omo Apr 27 '15 at 16:43
  • $\begingroup$ they are more likely just ints, with each of the ports defined in a header somewhere. $\endgroup$ – Octopus Apr 28 '15 at 21:59
1
$\begingroup$

Looking at some of the docs I see that the startMotor function usually takes values like portN as in:

startMotor(port8,-32);
startMotor(port9,128);

and I am also seeing that some code looks like this:

motor[port8] = -32;
motor[port9] = 128;

so that tells me that since it is an index into an array it must be just simply an int.

Update: I can see on this page that within VEX it is actually a variable of type tMotor. But it can't work as an index in C unless tMotor is an alias for some sort of int. Ultimately, the best choice would be to use tMotor in your code.

$\endgroup$
  • $\begingroup$ Have you confirmed this? $\endgroup$ – Ethan Bierlein Apr 28 '15 at 22:55
  • 1
    $\begingroup$ I found more info from a page I found for the ROBOTC language and added it to my answer. $\endgroup$ – Octopus Apr 29 '15 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.