SOS
I have a competition tomorrow, and my robot is being a stubborn idiot. It either runs the autonomous, even when the competition switch is not on it, and other times, I can drive, but the lift/claw will not work. Here is the code…
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, frontBump, sensorTouch)
#pragma config(Sensor, dgtl2, backBump, sensorNone)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, rightMotor, tmotorVex393_HBridge, openLoop, driveRight, encoderPort, I2C_1)
#pragma config(Motor, port3, liftMotors, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, peggy, tmotorServoStandard, openLoop)
#pragma config(Motor, port10, leftMotor, tmotorVex393_HBridge, openLoop, driveRight, encoderPort, I2C_2)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
//1.714285714 rotations per tile
//617.14285704 ticks per tile
//360 ticks per rotation
//154.28571426 ticks for a 90 degree
//308.57142852 ticks per half tile
bool Autonomous=false;
task main()
{
while(true){
if (Autonomous==false)
motor[leftMotor] = (vexRT[Ch3] + vexRT[Ch4])/2;
motor[rightMotor] = (vexRT[Ch3] - vexRT[Ch4])/2;
(vexRT[Btn6U] == 1);
motor[liftMotors] = 40;
if(vexRT[Btn6D] == 1)
motor[liftMotors] = -40;
}
{
nMotorEncoder[leftMotor]=0;
nMotorEncoder[rightMotor]=0;
while (nMotorEncoder[leftMotor]<308.57142852 && nMotorEncoder[rightMotor]<308.57142852){
motor[leftMotor]=127; //move forward 1/2 tile
motor[rightMotor]=127;
}
nMotorEncoder[leftMotor]=0;
nMotorEncoder[rightMotor]=0;
while(nMotorEncoder[leftMotor]<617.14285704 && nMotorEncoder[rightMotor]<617.14285704){
motor[rightMotor]=127; //move forward 1 tile
motor[leftMotor]=127;
}
nMotorEncoder[leftMotor]=0;
nMotorEncoder[rightMotor]=0;
while(nMotorEncoder[rightMotor]<308.57142852 && nMotorEncoder[leftMotor]<308.57142852){
motor[leftMotor]=127; //move forward half a tile
motor[rightMotor]=127;}
nMotorEncoder[leftMotor]=0;
nMotorEncoder[rightMotor]=0;
while(nMotorEncoder[rightMotor]<154.28571426 && nMotorEncoder[leftMotor]>-154.28571426){
motor[leftMotor]=127;
motor[rightMotor]=-127; //left turn
}
motor[leftMotor]=0;
motor[rightMotor]=0;
motor[liftMotors]=127;
sleep(1000); //raise the arm
while(nMotorEncoder[rightMotor]<154.28571426 && nMotorEncoder[leftMotor]<154.28571426){
motor[rightMotor]=127;
motor[leftMotor]=127; //move slightly forward
}
motor[peggy]=127;
sleep(200);
motor[peggy]=0;
while(nMotorEncoder[leftMotor]>-617.14285704 && nMotorEncoder[rightMotor]>-617.14285704){
nMotorEncoder[rightMotor]=-617.14285704; //move backward 1 tile
nMotorEncoder[leftMotor]=-617.14285704;}
while(nMotorEncoder[leftMotor]>-617.14285704 && nMotorEncoder[rightMotor]>-617.14285704){
nMotorEncoder[rightMotor]=-617.14285704; //move backward 1 tile
nMotorEncoder[leftMotor]=-617.14285704;}
while(nMotorEncoder[rightMotor]<154.28571426 && nMotorEncoder[leftMotor] >-154.285714268){
nMotorEncoder[rightMotor]=154.28571426;
nMotorEncoder[leftMotor]=-154.28571426; //backwards right turn
}
motor[liftMotors]=-127; // lower the lift
sleep(1000);
motor[liftMotors]=0;
motor[peggy]=-127; // slide on to mobile goal
sleep(1000);
motor[peggy]=-127;
Autonomous=false;
}
}