-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArcadeBot.c
214 lines (193 loc) · 5.65 KB
/
ArcadeBot.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#pragma config(Motor, port2, leftFrontDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, leftBackDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, rightFrontDrive, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, rightBackDrive, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, puncher, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, flipper, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, rubber, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//VEX Competition Control and Duration Settings (in seconds)
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(145)
#include "Vex_Competition_Includes.c"
//ArcadeBot
//Built for 2018 VEX Robotics Competition, "Turning Point"
//For WildStang B (111B) use only
//Developed by WhiteHoodHacker
/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// This is used to execute robot commands before the start of the VEX Competition.
// Modify the code to add specific robot commands 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
// Example: clearing encoders, setting servo positions, etc.
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control the robot during the autonomous phase of the VEX Competition.
// Modify the code to add robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task autonomous()
{
//Red Alliance Autonomous
motor[leftFrontDrive] = -100;
motor[leftBackDrive] = -100;
motor[rightFrontDrive] = -100;
motor[rightBackDrive] = -100;
motor[puncher] = 100;
wait1Msec(2000);
motor[puncher] = 0;
motor[leftFrontDrive] = 0;
motor[leftBackDrive] = 0;
motor[rightFrontDrive] = 0;
motor[rightBackDrive] = 0;
//Blue Alliance Autonomous (collab with 2360)
// motor[leftFrontDrive] = 100;
// motor[leftBackDrive] = 100;
// motor[rightFrontDrive] = 100;
// motor[rightBackDrive] = 100;
// wait1Msec(300);
// motor[leftFrontDrive] = 0;
// motor[leftBackDrive] = 0;
// motor[rightFrontDrive] = 0;
// motor[rightBackDrive] = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// User Control Task
//
// This task is used to control the robot during the user control phase of the VEX Competition.
// Modify the code to add robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task usercontrol()
{
//Variables for puncher toggle button
int puncherToggleState = 0;
int puncherButtonPressed = 0;
//Variables for intake toggle buttons
int intakeForwardToggleState = 0;
int intakeForwardButtonPressed = 0;
int intakeReverseToggleState = 0;
int intakeReverseButtonPressed = 0;
//Variables for rubber toggle buttons
int rubberToggleState = 0;
int rubberButtonPressed = 0;
while (true)
{
//Code for arcade drive (controlled by left joystick)
motor[leftFrontDrive] = vexRT[Ch3] + vexRT[Ch4];
motor[leftBackDrive] = vexRT[Ch3] + vexRT[Ch4];
motor[rightFrontDrive] = vexRT[Ch3] - vexRT[Ch4];
motor[rightBackDrive] = vexRT[Ch3] - vexRT[Ch4];
//Code for intake (controlled by 8D button (forwards) and 7D button (reverse))
if(vexRT[Btn8D] == 1)
{
if(! intakeForwardButtonPressed)
{
intakeForwardToggleState = 1 - intakeForwardToggleState;
intakeForwardButtonPressed = 1;
}
}
else
{
intakeForwardButtonPressed = 0;
}
if(intakeForwardToggleState)
{
intakeReverseToggleState = 0;
intakeReverseButtonPressed = 0;
motor[intake] = 50;
}
else
{
if(! intakeReverseToggleState)
{
motor[intake] = 0;
}
}
if(vexRT[Btn7D] == 1)
{
if(! intakeReverseButtonPressed)
{
intakeReverseToggleState = 1 - intakeReverseToggleState;
intakeReverseButtonPressed = 1;
}
}
else
{
intakeReverseButtonPressed = 0;
}
if(intakeReverseToggleState)
{
intakeForwardToggleState = 0;
intakeForwardButtonPressed = 0;
motor[intake] = -50;
}
else
{
if(! intakeForwardToggleState)
{
motor[intake] = 0;
}
}
//Code for puncher (controlled by 6D button)
if(vexRT[Btn6D] == 1)
{
if(! puncherButtonPressed)
{
puncherToggleState = 1 - puncherToggleState;
puncherButtonPressed = 1;
}
}
else
{
puncherButtonPressed = 0;
}
if(puncherToggleState)
{
motor[puncher] = 100;
}
else
{
motor[puncher] = 0;
}
//Code for flipper (controlled by right joystick)
motor[flipper] = vexRT[Ch2];
//Code for rubber (controlled by 8R button)
if(vexRT[Btn8R] == 1)
{
if(! rubberButtonPressed)
{
rubberToggleState = 1 - rubberToggleState;
rubberButtonPressed = 1;
}
}
else
{
rubberButtonPressed = 0;
}
if(rubberToggleState)
{
motor[rubber] = 100;
}
else
{
motor[rubber] = 0;
}
}
}