This repository was archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2MotorCompetition.c
More file actions
71 lines (57 loc) · 2.74 KB
/
2MotorCompetition.c
File metadata and controls
71 lines (57 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma config(Motor, port2, leftMotor, tmotorNormal, openLoop,)
#pragma config(Motor, port3, rightMotor, tmotorNormal, openLoop, reversed)
#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
//
// INITALIZE FUNCTIONS FOR AUTONOMOUS pre_auton FUNCTION HERE
//
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// All activities that occur before the competition starts
// Such as resetting motor encoder values, setting motors to specific positions
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
// .....................................................................................
// Insert user code here.
// .....................................................................................
//AutonomousCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
}
// Vex Controler Joystick and button list
// Right Joystick X axis movement is on Ch1
// Right Joystick Y axis movement is on Ch2
// Left Joystick X axis movement is on Ch3
// Left Joystick Y axis movement is on Ch4
// Right Keypad buttons are [Btn8U], [Btn8R], [Btn8D] or [Btn8L] with (U,R,D,L) corresponding to Up, Right, Down and Left
// Left Keypad buttons are [Btn7U], [Btn7R], [Btn7D] or [Btn7L]
// Right Trigger buttons are [Btn6U] and [Btn6D] with U and D corresponding to Up and Down
// Left Trigger buttons are [Btn5U] and [Btn5D]
task usercontrol()
{
// Put User control code in the loop below, so that it runs perpetually
while (true) //While 1 == 1 would also work here. Just saying.
{
//Slightly more complex Tank Controls code
motor[leftMotor] = (vexRT[Ch4] + vexRT[Ch3])/2; //(y channel + x channel)/2
motor[rightMotor] = (vexRT[Ch2] - vexRT[Ch1])/2; //(y channel - x channel)/2
}
}