View Single Post
  #2   Spotlight this post!  
Unread 29-09-2016, 16:31
pjt0620 pjt0620 is offline
Registered User
no team
 
Join Date: Sep 2016
Location: Livonia MI,
Posts: 4
pjt0620 is an unknown quantity at this point
Re: [OCCRA]: OCCRA Software Template for RobotC

Here is a simple example of a tank drive with the left motor being on pwm 1 and the right motor being on pwm 2
Code:
/*
Basic OCCRA Tank drive example
Disclaimer: Not tested due to lack of cortex
*/
#pragma platform(VEX2) //This is to tell the compiler that you are using the cortex
#pragma competitionControl(Competition) //This tells the compiler that your robot will have to listen to the field for when it can go
#include "Vex_Competition_Includes.c" //This is telling it how the field will talk to it

//Here we assign variables to more friendly names 
int leftMotor = port1;
int rightMotor = port2;
//Refrence guide for controler at http://www.robotc.net/wikiarchive/VEX2_Functions_Remote_Control_-_VEXnet
int leftJoystick = Ch3;
int rightJoystick = Ch2;
//End of declarations



void pre_auton(){}//This is a function used to set up tasks before the match
task autonomous(){}//This is a function used for an autonomous mode, OCCRA does not have autonomous modes so ignore this function
task usercontrol()//When the match begins the field tells the cortex to run the code in this function
{
	while (true) //This function tells your robot to keep running the code inside this loop
	{
		motor[leftMotor] = vexRT[leftJoystick]; //Here we set the speed of the left motor, -127 being full reverse 0 being neutral and 127 being full forward to the left joysticks output
		motor[rightMotor] = vexRT[rightJoystick]; //Here we set the speed of the right motor, -127 being full reverse 0 being neutral and 127 being full forward to the right joysticks output
	}
}
Reply With Quote