I made a ROBOTC algorithm with this code:
#pragma config(Motor, port1, Climbmotor1, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, Rmotor2, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port3, Climbmotor3, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, Larmmotor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, Lmotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port6, Rmotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port7, Rarmmotor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, Lmotor2, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port9, Clawmotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port10, Climbmotor2, tmotorVex269_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*----------------------------------------------------------------------------------------------------*\
|* - Dual Joystick Control with Arm - 1 Remote - *|
|* ROBOTC on VEX 2.0 Cortex *|
|* *|
|* This program uses both the Left and the Right joysticks to run the robot using "tank control". *|
|* The Group 6 buttons on the top-right of the VEXnet Joystick are used to raise and lower an arm. *|
|* *|
|* ROBOT CONFIGURATION *|
|* NOTES: *|
|* 1) Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick. *|
|* 2) Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick. *|
|* *|
|* MOTORS & SENSORS: *|
|* * [Name] [Type] [Description] *|
|* Motor - Port 2 rightMotor VEX Motor Right motor *|
|* Motor - Port 3 leftMotor VEX Motor Left motor *|
|* Motor - Port 6 armMotor VEX Motor Arm motor *|
\*----------------------------------------------------------------------------------------------------*/
//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
//The value of the last button that was down. Is set to 0 initially because no button should be pressed at the beginning of the match.
int lastButtonValue = 0;
//Returns the current button being pressed. 0 if no button pressed.
int buttonValue() {
if(vexRT[Btn8D] == 1) {
return Btn8D;
}
else if(vexRT[Btn8R] == 1) {
return Btn8R;
}
else if(vexRT[Btn6U] == 1) {
return Btn6U;
}
else if(vexRT[Btn6D] == 1) {
return Btn6D;
}
else if(vexRT[Btn5U] == 1) {
return Btn5U;
}
else if(vexRT[Btn5D] == 1) {
return Btn5D;
}
else if(vexRT[Btn7D] == 1) {
return Btn7D;
}
else if(vexRT[Btn8U] == 1) {
return Btn8U;
}
else if(vexRT[Btn8L] == 1) {
return Btn8L;
}
else if(vexRT[Btn7U] == 1) {
return Btn7U;
}
else {
return 0;
}
}
//Returns 1 if the last button you pressed is the specified button. Returns 0 if it isn't.
int didPressButton(int button) {
//If the last button that was down is the specified button and no buttons are currently being pressed
if (lastButtonValue == button && buttonValue() == 0) {
return 1;
}
else {
return 0;
}
}
/**When the match starts**/
task main()
{
//Forever
while(true)
{
/**Driving controls**/
//Forward button: 7U
if(didPressButton(Btn7U)) {
motor[Lmotor] = 127;
motor[Rmotor] = 127;
}
//Backward button: 7D
else if(didPressButton(Btn7D)) {
motor[Lmotor] = -127;
motor[Rmotor] = -127;
}
//Wheel brake: 8L
else if(didPressButton(Btn8L)) {
motor[Lmotor] = 0;
motor[Rmotor] = 0;
}
/**Pivot controls**/
//If the Left Joystick's Y axis is greater than 70
if(vexRT[Ch4] > 70) {
motor[Lmotor] = 127;
motor[Rmotor] = -127;
}
//If the Left Joystick's Y axis is less than -70
else if(vexRT[Ch4] < -70) {
motor[Rmotor] = 127;
motor[Lmotor] = -127;
}
/**Arm controls**/
//Arm Up button: 6U
if(didPressButton(Btn6U) == 1) {
motor[Rarmmotor] = 127;
motor[Larmmotor] = 127;
}
//Arm Down Button: 6D
else if(didPressButton(Btn6D) == 1) {
motor[Rarmmotor] = -75;
motor[Larmmotor] = -75;
}
//Arm Brake: 8D
else if(didPressButton(Btn8D) == 1) {
motor[Rarmmotor] = 30;
motor[Larmmotor] = 30;
}
/**Claw controls**/
//Claw Up button: 5U
if(didPressButton(Btn5U) == 1) {
motor[Clawmotor] = 127;
}
//Claw Down Button: 5D
else if(didPressButton(Btn5D) == 1) {
motor[Clawmotor] = -127;
}
//Claw Brake: 8U
else if(didPressButton(Btn8U) == 1) {
motor[Clawmotor] = 20;
}
//Set the value of the last button that was down
lastButtonValue = buttonValue();
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(file attached)
And it didn’t have any errors when I initially compiled it, but upon opening it about the 10th time, errors showed up. The errors were talking about undefined variables, but those are the buttons I was using. It was working fine before, but now has errors. Even after compiling again, the errors stayed.
Log:
File “E:\2017.18 VEX\Software\Ptolemy’s 1st.c” compiled on Sep 25 2017 16:17:07
Error:Undefined variable ‘Btn8D’. ‘short’ assumed.
Error:Undefined variable ‘Btn8R’. ‘short’ assumed.
Error:Undefined variable ‘Btn6U’. ‘short’ assumed.
Error:Undefined variable ‘Btn6D’. ‘short’ assumed.
Error:Undefined variable ‘Btn5U’. ‘short’ assumed.
Error:Undefined variable ‘Btn5D’. ‘short’ assumed.
Error:Undefined variable ‘Btn7D’. ‘short’ assumed.
Error:Undefined variable ‘Btn8U’. ‘short’ assumed.
Error:Undefined variable ‘Btn8L’. ‘short’ assumed.
Error:Undefined variable ‘Btn7U’. ‘short’ assumed.
Error:Undefined variable ‘Ch4’. ‘short’ assumed.*