Skip to content

Instantly share code, notes, and snippets.

@jononon
Created November 5, 2016 06:34
Show Gist options
  • Save jononon/31adeaae2306d89972eb3772f8ae9261 to your computer and use it in GitHub Desktop.
Save jononon/31adeaae2306d89972eb3772f8ae9261 to your computer and use it in GitHub Desktop.
#pragma config(Sensor, dgtl1, liftBottom, sensorTouch)
#pragma config(Motor, port1, liftL3, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, liftR1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, liftR2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, leftDrive, tmotorVex393HighSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port5, liftL1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, liftL2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, rightDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port8, , tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port9, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, liftR3, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"
void lift(int power){
motor[liftL1]=power;
motor[liftL2]=power;
motor[liftL3]=power;
motor[liftR1]=power;
motor[liftR2]=power;
motor[liftR3]=power;
}
void lift(){
if(vexRT[Btn5U]){
lift(127);
}
else if(SensorValue(liftBottom)==1){
lift(0);
}
else if(vexRT[Btn5D]){
lift(-127);
}
else{
lift(10);
}
}
void drive(){
motor[rightDrive]=vexRT[Ch2];
motor[leftDrive]=vexRT[Ch3];
}
void pre_auton() {}
bool applyPressure = false;
void intaker(){
if(vexRT[Btn6U]){
motor[intake]=127;
applyPressure = true;
}
else if(vexRT[Btn6D]){
motor[intake]=-90;
applyPressur
e = false;
}
else{
motor[intake]=applyPressure*20;
}
}
task autonomous {
lift(127);
wait1Msec(200);
lift(0);
motor[leftDrive] = 127;
motor[rightDrive] = 127;
wait1Msec(300);
motor[intake]=127;
wait1Msec(400);
motor[intake]=0;
wait1Msec(300);
motor[leftDrive] = 0;
motor[rightDrive] = 0;
lift(127);
wait1Msec(350);
motor[leftDrive] = 127;
motor[rightDrive] = 127;
wait1Msec(350);
lift(0);
wait1Msec(200);
motor[leftDrive] = 0;
motor[rightDrive] = 0;
}
task usercontrol(){
while(true){
drive();
lift();
//claw();
intaker();
wait1Msec(15);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment