-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
84 lines (71 loc) · 2.88 KB
/
main.cpp
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
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: C:\Users\kkand */
/* Created: Tue Nov 26 2019 */
/* Description: V5 project */
/* */
/*----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// LeftFront motor 1
// LeftBack motor 11
// RightFront motor 10
// RightBack motor 20
// LeftBackLift motor 15
// RightBackLift motor 17
// Front motor 4
// ---- END VEXCODE CONFIGURED DEVICES ----
// MOTOR.setStopping(coast)
#include "vex.h"
using namespace vex;
void tankDrive(){
double leftStick = Controller1.Axis3.value();
double rightStick = Controller1.Axis2.value();
LeftFront.spin(vex::directionType::fwd, leftStick, vex::velocityUnits::pct);
LeftBack.spin(vex::directionType::fwd, leftStick, vex::velocityUnits::pct);
RightFront.spin(vex::directionType::rev, rightStick, vex::velocityUnits::pct);
RightBack.spin(vex::directionType::rev, rightStick, vex::velocityUnits::pct);
}
void lift(){
LeftBackLift.spin(vex::directionType::fwd, 35, vex::velocityUnits::pct);
RightBackLift.spin(vex::directionType::fwd, 35, vex::velocityUnits::pct);
}
void grab(){
Front.spin(vex::directionType::fwd, 35, vex::velocityUnits::pct);
}
void release(){
Front.spin(vex::directionType::rev, 35, vex::velocityUnits::pct);
}
void goDown(){
LeftBackLift.spin(vex::directionType::rev, 35, vex::velocityUnits::pct);
RightBackLift.spin(vex::directionType::rev, 35, vex::velocityUnits::pct);
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
while(1){
tankDrive();
if(Controller1.ButtonR1.pressing()){
grab();
} else if(Controller1.ButtonR2.pressing()){
release();
} else {
Front.stop();
}
if(Controller1.ButtonL1.pressing()){
lift();
} else if(!Controller1.ButtonL1.pressing()){
LeftBackLift.setStopping(coast);
RightBackLift.setStopping(coast);
}
if(Controller1.ButtonL2.pressing()){
goDown();
} else if(!(Controller1.ButtonL2.pressing())){
LeftBackLift.setStopping(coast);
RightBackLift.setStopping(coast);
}
}
}