Team 80 2010 Code
From DEW Robotics
Revision as of 01:46, 22 February 2010 by Foster (talk | contribs) (Created page with 'This is the code base for Team 80 in 2010. This code scored 21 points in autonomous mode. <source lang="c"> #pragma config(Sensor, in1, potArm, sensorPotentiome...')
This is the code base for Team 80 in 2010. This code scored 21 points in autonomous mode.
#pragma config(Sensor, in1, potArm, sensorPotentiometer)
#pragma config(Sensor, in2, potBasket, sensorPotentiometer)
#pragma config(Sensor, in11, limitArm, sensorTouch)
#pragma config(Sensor, in12, buttonBack, sensorTouch)
#pragma config(Motor, port2, motorRight, tmotorNormal, openLoop)
#pragma config(Motor, port3, motorLeft, tmotorNormal, openLoop)
#pragma config(Motor, port5, motorBasket, tmotorNormal, openLoop)
#pragma config(Motor, port6, motorArm, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
bMotorReflected[motorRight]=true;
bMotorReflected[motorBasket]= true;
bMotorReflected[motorArm]=false;
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task autonomous()
{
// drive forward --
motor[motorRight] = -127;
motor[motorLeft] = -127;
wait1Msec(3000);
// at the wall, stop the motors
motor[motorRight] = 0;
motor[motorLeft] = 0;
// dump the basket (run for 4 seconds)
motor[motorBasket] = 127;
wait1Msec(4500);
// stop the basket
motor[motorBasket] = 0;
// wiggle side-to-side
motor[motorRight] = 127;
motor[motorLeft] = -127;
wait1Msec(500);
// wiggle the other way
motor[motorRight] = -127;
motor[motorLeft] = 127;
wait1Msec(1500);
// wiggle back to center
motor[motorRight] = 127;
motor[motorLeft] = -127;
wait1Msec(700);
// back up
motor[motorRight] = 127;
motor[motorLeft] = 127;
wait1Msec(2500);
// turn to center
motor[motorRight] = -127;
motor[motorLeft] = 127;
wait1Msec(3000);
// move to center
motor[motorRight] = -127;
motor[motorLeft] = -127;
wait1Msec(2000);
//turn toward wall
motor[motorRight] = 127;
motor[motorLeft] = -127;
wait1Msec(3000);
// approach the wall
motor[motorRight] = -127;
motor[motorLeft] = -127;
wait1Msec(2500);
// turn to run along the wall
motor[motorRight] = -127;
motor[motorLeft] = 127;
wait1Msec(3000);
// knock off the three footballs
motor[motorRight] = -127;
motor[motorLeft] = -127;
wait1Msec(2000);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task usercontrol()
{
// User control code here, inside the loop
while (true)
{
motor[motorRight] = vexRT(Ch2);
motor[motorLeft] = vexRT(Ch3);
motor[motorArm] = vexRT(Ch6Xmtr2);
motor[motorBasket] = vexRT(Ch5Xmtr2);
}
}