Skip to content

Instantly share code, notes, and snippets.

@Synvox
Created February 29, 2012 14:42
Show Gist options
  • Save Synvox/1941266 to your computer and use it in GitHub Desktop.
Save Synvox/1941266 to your computer and use it in GitHub Desktop.
Robot C Vex
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(122)
#include "Vex_Competition_Includes.c"
typedef struct {
int left;
int right;
int arm;
int lift;
int servo;
} Robot_Struct;
Robot_Struct Robot;
void pre_auton()
{
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
task autonomous()
{
AuonomousCodePlaceholderForTesting();
}
void useTank(){
Robot.left=vexRT[Ch2];
Robot.right=vexRT[Ch3];
}
void moveArm(){
Robot.arm=vexRT[Ch3Xmtr2];
}
void moveForkLift(){
Robot.lift=vexRT[Ch2Xmtr2];
}
void useServo() {
Robot.servo=-32;
if (vexRT[Btn6UXmtr2])
Robot.servo=96;
else if (vexRT[Btn6DXmtr2])
Robot.servo=-64;
}
void getRobot(){}
void setRobot(){
motor[port1]=Robot.left;
motor[port2]=Robot.right;
motor[port4]=-Robot.arm;
motor[port5]=motor[port4];
motor[port3]=-Robot.lift;
motor[port6]=Robot.servo;
}
task usercontrol()
{
Robot.left=0;
Robot.right=0;
Robot.arm=0;
Robot.lift=0;
Robot.servo=0;
while (true)
{
getRobot();
useTank();
moveArm();
moveForkLift();
useServo();
setRobot();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment