#pragma config(Sensor, in1, autoPot1, sensorPotentiometer) #pragma config(Sensor, in2, autoPot2, sensorPotentiometer) #pragma config(Sensor, dgtl1, liftEncoder, sensorQuadEncoder) #pragma config(Sensor, in3, e-stop, sensorTouch) #pragma config(Motor, port2, intakeRight, tmotorNormal, openLoop, reversed) #pragma config(Motor, port3, intaketLeft, tmotorNormal, openLoop) #pragma config(Motor, port4, liftRightU, tmotorNormal, openLoop) #pragma config(Motor, port5, liftRightD, tmotorNormal, openLoop, reversed) #pragma config(Motor, port6, liftLeftU, tmotorNormal, openLoop) #pragma config(Motor, port7, liftleftD, tmotorNormal, openLoop, reversed) #pragma config(Motor, port8, rightDrive, tmotorNormal, openLoop) #pragma config(Motor, port9, leftDrive, tmotorNormal, openLoop, reversed) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// #pragma platform(VEX) //Competition Control and Duration Settings #pragma competitionControl(Competition) #pragma autonomousDuration(20) #pragma userControlDuration(120) #include "Vex_Competition_Includes.c" //Main competition background code...do not modify! void pre_auton() { SensorValue[liftEncoder] = 0; } void lift(int speed) { motor[port7] = speed; motor[port6] = speed; motor[port5] = speed; motor[port4] = speed; } void intake(int speed1) { motor[port3] = speed1; motor[port2] = speed1; } void drive(int speed2) { motor[port9] = speed2; motor[port8] = speed2; } void turnRight(int time) { motor[port9] = -40; motor[port8] = 40; wait1Msec(time); motor[port9] = 0; motor[port8] = 0; } void turnLeft(int time2) { motor[port9] = 40; motor[port8] = -40; wait1Msec(time2); motor[port9] = 0; motor[port8] = 0; } task auto() { if(SensorValue[autoPot1] > 0 || SensorValue[autoPot1] < 500) { while(SensorValue[liftEncoder] < 1250) { lift(127); } lift(0); intake(127); wait1Msec(2500); intake(0); wait1Msec(100); drive(40); wait1Msec(50); drive(0); wait1Msec(500); drive(-63); wait1Msec(200); drive(0); wait1Msec(100); turnRight(1300); wait1Msec(100); drive(40); wait1Msec(800); drive(0); while(SensorValue[liftEncoder] > 200) { lift(-127); intake(127); } lift(0); wait1Msec(1000); intake(0); while(SensorValue[liftEncoder] < 400) { lift(127); } lift(0); drive(40); wait1Msec(600); drive(0); while(SensorValue[liftEncoder] > 100) { lift(-127); } lift(0); intake(127); wait1Msec(200); intake(0); drive(63); wait1Msec(100); drive(0); turnLeft(1000); drive(63); wait1Msec(500); drive(0); turnRight(50); intake(127); wait1Msec(3000); intake(0); } if (SensorValue[autoPot1] > 1000 || SensorValue[autoPot1] < 1500) { SensorValue[liftEncoder] = 0; while(SensorValue[liftEncoder] < 1250) { lift(127); } lift(0); intake(127); wait1Msec(2500); intake(0); wait1Msec(100); drive(40); wait1Msec(50); drive(0); wait1Msec(500); drive(-63); wait1Msec(200); drive(0); wait1Msec(100); turnLeft(1300); wait1Msec(100); drive(40); wait1Msec(800); drive(0); while(SensorValue[liftEncoder] > 200) { lift(-127); intake(127); } lift(0); wait1Msec(1000); intake(0); while(SensorValue[liftEncoder] < 400) { lift(127); } lift(0); drive(40); wait1Msec(600); drive(0); while(SensorValue[liftEncoder] > 100) { lift(-127); } lift(0); intake(127); wait1Msec(200); intake(0); drive(63); wait1Msec(100); drive(0); turnRight(1000); drive(63); wait1Msec(500); drive(0); turnLeft(50); intake(127); wait1Msec(3000); intake(0); } } task kill() { while(true) { if(SensorValue[e-stop] = 0) { //do nothing } else { StopTask(auto); StopTask(kill); } wait1Msec(10); } } task autonomous() { StartTask(auto); StartTask(kill); while(True); { } } task one() { while(1==1) { //drive motor[port9] = vexRT[Ch2]; motor[port8] = vexRT[Ch3]; //lift if(vexRT[btn6U] == 1) { motor[port4] = 127; motor[port5] = 127; motor[port6] = 127; motor[port7] = 127; } else if(vexRT[btn6D] == 1) { motor[port4] = -127; motor[port5] = -127; motor[port6] = -127; motor[port7] = -127; } else { motor[port4] = 0; motor[port5] = 0; motor[port6] = 0; motor[port7] = 0; } //intake if(vexRT[btn5U] == 1) { motor[port3] =127; motor[port2] = 127; } else if(vexRT[btn5D] == 1) { motor[port3] = -127; motor[port2] = -127; } else { motor[port3] = 0; motor[port2] = 0; } wait1Msec(10); } } task two() { while(true) { //low goal if(vexRT[btn8D] == 1) { if(SensorValue[liftEncoder] < 100) { motor[port4] = 127; motor[port5] = 127; motor[port6] = 127; motor[port7] = 127; } else if(SensorValue[liftEncoder] > 100) { motor[port4] = -127; motor[port5] = -127; motor[port6] = -127; motor[port7] = -127; } else { motor[port4] = 0; motor[port5] = 0; motor[port6] = 0; motor[port7] = 0; } } //medium goal if(vexRT[Btn8L] == 1) { if(SensorValue[liftEncoder] < 500) { motor[port4] = 127; motor[port5] = 127; motor[port6] = 127; motor[port7] = 127; } else if(SensorValue[liftEncoder] > 500) { motor[port4] = -127; motor[port5] = -127; motor[port6] = -127; motor[port7] = -127; } else { motor[port4] = 0; motor[port5] = 0; motor[port6] = 0; motor[port7] = 0; } } //high goal if(vexRT[Btn8U] == 1) { if(SensorValue[liftEncoder] < 1000) { motor[port4] = 127; motor[port5] = 127; motor[port6] = 127; motor[port7] = 127; } else if(SensorValue[liftEncoder] > 1000) { motor[port4] = -127; motor[port5] = -127; motor[port6] = -127; motor[port7] = -127; } else { motor[port4] = 10; motor[port5] = 10; motor[port6] = 10; motor[port7] = 10; } } wait1Msec(10); } } task usercontrol() { StartTask(one); StartTask(two); while(true) { } }