-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pre-comp2 code.c
150 lines (136 loc) · 3.21 KB
/
Pre-comp2 code.c
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#pragma config(Motor, port2, motor1, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, motor2, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, motor3, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port5, motor4, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port6, ball_motor5, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port7, launcy_boi, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, shooter_angle, tmotorServoStandard, openLoop)
#pragma config(Motor, port9, cap_flipper, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
// Vex Team 45501E
// ports 2&3 are left, ports 4&5 are right, port5 is for capture mechanism
// 6U is Intake, 5U is spit, and 5D & 6D are stop
// 8D is pull
// 7L and 7D adjust angle
// 8U and 8L are cap flip
#pragma platform(VEX)
// Competition Control
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
int ball_loader;
int ball_launch;
int launch_angle;
int cap_toss;
int servo_slow;
void pre_auton()
{
bStopTasksBetweenModes = true;
}
task autonomous()
{
motor[port2] = 127;
motor[port3] = 127;
motor[port4] = 127;
motor[port5] = 127;
wait(2, seconds);
motor[port2] = -127;
motor[port3] = -127;
motor[port4] = -127;
motor[port5] = -127;
wait(1860, milliseconds);
startTask(usercontrol);
}
task usercontrol()
{
cap_toss = 120;
while ( 1 == 1 )
{
//Drive
tankControl(Ch2, Ch3, 10);
// Autonomous Start and Tele-op Stop
if(vexRT[Btn7U] == 1)
{
startTask(autonomous);
stopTask(usercontrol);
}
// Ball Spinny Thing (BPU)
// 6U is Intake, 5U is spit, and 5D & 6D are stop
// Normal rotation
if(vexRT[Btn6U] == 1)
{
ball_loader = 127;
}
else if(vexRT[Btn6D] == 1)
{
ball_loader = 0;
ball_launch = 0;
}
// Reversed Rotation
else if(vexRT[Btn5U] == 1)
{
ball_loader = -127;
}
else if(vexRT[Btn5D] == 1)
{
ball_loader = 0;
ball_launch = 0;
}
motor[port6] = ball_loader;
// Ball Launch Start
// 8D is pull
if(vexRT[Btn8D] == 1)
{
ball_launch = 127;
}
motor[port7] = ball_launch;
// Ball launch angle servo
// 7L and 7D adjust angle
if(vexRT[Btn7L] == 1)
{
servo_slow = servo_slow + 1;
if(servo_slow > 30)
{
servo_slow = 0;
if(launch_angle < 127)
{
launch_angle = launch_angle + 1;
}
if(launch_angle > 127)
{
launch_angle = 120;
}
}
}
else if(vexRT[Btn7D] == 1)
{
servo_slow = servo_slow + 1;
if(servo_slow > 30)
{
servo_slow = 0;
if(cap_toss > -127)
{
launch_angle = launch_angle -1;
}
if(launch_angle < -127)
{
launch_angle = -120;
}
}
}
motor[port8] = launch_angle;
// Cap flippin' servo
// 8U and 8L are cap flip
if(vexRT[Btn8U] == 1)
{
cap_toss = 128;
}
else if(vexRT[Btn8L] == 1)
{
cap_toss = 0;
}
motor[port9] = cap_toss;
wait(50, milliseconds);
}
}