hey, my name is Marshall from team 11761B, and I am having problems in my program, where when I use a switch() case: it is giving me compiler errors. If anybody could tell me how to fix this it would be very helpful.
#pragma config(Sensor, dgtl1, rightencoder, sensorRotation)
#pragma config(Sensor, dgtl2, leftencoder, sensorRotation)
#pragma config(Motor, port1, rightmotor, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, leftmotor, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
void driveDirection(void ydirection, float inches, int power)
{
SensorValue[rightencoder] = 0;
SensorValue[leftencoder] = 0;
int dir = 0;
switch(ydirection)
{
case forward:
dir = 1;
break;
case backward:
dir = -1;
break;
default:
dir = 1;
break;
}
int drivegoal = (inches * 49.9109902106);
while(SensorValue[rightencoder] * dir < drivegoal || SensorValue[leftencoder] * dir < drivegoal)
{
motor[rightmotor] = (dir * power);
motor[leftmotor] = (dir * power);
}
{
motor[rightmotor] = 0;
motor[leftmotor] = 0;
}
}
//void driveBackward(float inches, int power) //New
//{
// SensorValue[rightencoder] = 0;
// SensorValue[leftencoder] = 0;
//
// float drivegoal = -(inches * 49.9109902106);
//
// while(SensorValue[rightencoder] > drivegoal || SensorValue[leftencoder] > drivegoal)
// {
// motor[rightmotor] = -power;
// motor[leftmotor] = -power;
// }
//
// {
// motor[rightmotor] = 0;
// motor[leftmotor] = 0;
// }
//}
void Turn(void direction, int degrees, int power)
{
SensorValue[rightencoder] = 0;
SensorValue[leftencoder] = 0;
int dir = 0;
switch(direction)
{
case right:
dir = 1;
break;
case left:
dir = -1;
break;
}
float turngoal = (degrees * 6.09777777778);
while(SensorValue[leftencoder] * dir < turngoal || SensorValue[rightencoder] * dir > -turngoal)
{
motor[leftmotor] = dir * power;
motor[rightmotor] = -dir * power;
}
{
motor[leftmotor] = 0;
motor[rightmotor] = 0;
}
}
// if(direction == Right)
// {
// while(abs(SensorValue[leftencoder] > turngoal || SensorValue[rightencoder] < -turngoal))
// {
// motor[rightmotor] = -power;
// motor[leftmotor] = power;
// }
//
// {
// motor[leftmotor] = 0;
// motor[rightmotor] = 0;
// }
// }
//
// if(direction == Left)
// {
// while(abs(SensorValue[rightencoder] > turngoal || SensorValue[leftencoder] < -turngoal))
// motor[rightmotor] = power;
// motor[leftmotor] = -power;
// }
//
// {
// motor[leftmotor] = 0;
// motor[rightmotor] = 0;
// }
// }
//}
void move(void xdirection, float amount, int power) //New
{
switch(xdirection)
{
case forward:
driveDirection(xdirection, amount, power);
break;
case left:
Turn(xdirection, amount, power);
break;
case right:
Turn(xdirection, amount, power);
break;
case backward:
driveDirection(xdirection, amount, power);
break;
}
}
task main() //Use move(direction, amountif direction = left/right degrees, if direction = forward/backward use inches)
{
//Put code in here
move(left, 90, 90);
}