Skip to content

Instantly share code, notes, and snippets.

@liamariemb
Created September 21, 2016 04:35
Show Gist options
  • Save liamariemb/3702e98669e192e992fdcf74cfa13f85 to your computer and use it in GitHub Desktop.
Save liamariemb/3702e98669e192e992fdcf74cfa13f85 to your computer and use it in GitHub Desktop.
#pragma config(Sensor, dgtl10, BumperLeft, sensorTouch)
#pragma config(Sensor, dgtl11, BumperRight, sensorTouch)
#pragma config(Sensor, dgtl12, BumperMiddle, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*----------------------------------------------------------------------------------------------------*\
|* - Moving Forward - *|
|* ROBOTC on VEX 2.0 CORTEX *|
|* *|
|* This program instructs your robot to move forward at full power for three seconds. There is a *|
|* two second pause at the beginning of the program. *|
|* *|
|* ROBOT CONFIGURATION *|
|* NOTES: *|
|* 1) Reversing 'rightMotor' (port 2) in the "Motors and Sensors Setup" is needed with the *|
|* "Squarebot" mode, but may not be needed for all robot configurations. *|
|* 2) Power levels that can be assigned to a motor port range from -127 (full reverse) to *|
|* 127 (full forward). *|
|* *|
|* MOTORS & SENSORS: *|
|* [I/O Port] [Name] [Type] [Description] *|
|* Motor Port 2 rightMotor VEX 3-wire module Right side motor *|
|* Motor Port 3 leftMotor VEX 3-wire module Left side motor *|
\*-----------------------------------------------------------------------------------------------4246-*/
//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
task main()
{ while(1==1)
{ motor[rightMotor] = 40;
motor[leftMotor] = 50;
if (SensorValue[BumperMiddle]==1)
{ motor[rightMotor] = -20;
motor[leftMotor] = -28;
wait1Msec(1000);
motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(1000);
motor[rightMotor] = 40;
motor[leftMotor] = -50;
wait1Msec(750);
}
if (SensorValue[BumperRight]==1)
{ motor[rightMotor] = -20;
motor[leftMotor] = -28;
wait1Msec(1000);
motor[rightMotor] = 30;
motor[leftMotor] = 0;
wait1Msec(1000);
}
if (SensorValue[BumperLeft]==1)
{ motor[rightMotor] = -20;
motor[leftMotor] = -28;
wait1Msec(1000);
motor[rightMotor] = 0;
motor[leftMotor] = 30;
wait1Msec(1500);
}
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment