Quote:
Originally Posted by lopsided98
You can, but you just can't create the motor controller within that function. You need to create it when the robot starts, but then you can set its speed in the function.
|
Will this work
Code:
int motorAutomationEncoder(double encoderDist,
double encoderDistThresholdMax,
double encoderDistThresholdMin,
CANTalon motor,
double motorSpeed)
{
if(encoderDist > encoderDistThresholdMax) {
motor.Set(0.0);
}
else if(encoderDist <= encoderDistThresholdMax && encoderDist >= encoderDistThresholdMin) {
motor.Set(motorSpeed);
}
else if(encoderDist < encoderDistThresholdMin) {
motor.Set(0.0);
}
}
As aforementioned, the start-stop loop seems to have disappeared.