Skip to content

Instantly share code, notes, and snippets.

@jononon
Created November 5, 2016 06:35
Show Gist options
  • Save jononon/98cfebe58a1f115e4d8ae4d164f0ea38 to your computer and use it in GitHub Desktop.
Save jononon/98cfebe58a1f115e4d8ae4d164f0ea38 to your computer and use it in GitHub Desktop.
#pragma config(Sensor, dgtl1, liftBottom, sensorTouch)
#pragma config(Motor, port1, liftRI, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, liftRO, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, liftLI, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, liftLO, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, intake1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, intake2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, leftDrive1, tmotorVex393HighSpeed_MC29, openLoop, driveRight)
#pragma config(Motor, port8, leftDrive2, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port9, rightDrive1, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port10, rightDrive2, tmotorVex393HighSpeed_HBridge, openLoop, reversed)
//*!!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[liftLI]=power;
motor[liftLO]=power;
motor[liftRI]=power;
motor[liftRO]=power;
}
void lift(){
if(vexRT[Btn5U]){
lift(127);
}
else if(SensorValue(liftBottom)==1){
lift(0);
}
else if(vexRT[Btn5D]){
lift(-127);
}
else{
lift(15);
}
}
void claw () {
if(vexRT[Btn6U]) {
motor[intake1] = 127;
motor[intake2] = 127;
} else if (vexRT[Btn6D]) {
motor[intake1] = -127;
motor[intake2] = -127;
} else {
motor[intake1] = 0;
motor[intake2] = 0;
}
}
int deadbands = 13;
void drive(){
int right = abs(vexRT[Ch2])<deadbands?0:vexRT[Ch2];
int left = abs(vexRT[Ch3])<deadbands?0:vexRT[Ch3];
motor[rightDrive1]=right;
motor[rightDrive2]=right;
motor[leftDrive1]=left;
motor[leftDrive2]=left;
}
void pre_auton() {}
void intaker(){
if(vexRT[Btn6U]){
motor[intake1]=127;
motor[intake2]=127;
}
else if(vexRT[Btn6D]){
motor[intake1]=-127;
motor[intake2]=-127;
}
else{
motor[intake1]=5;
motor[intake2]=5;
}
}
task autonomous {
}
task usercontrol(){
while(true){
drive();
lift();
claw();
intaker();
wait1Msec(25);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment