-
Notifications
You must be signed in to change notification settings - Fork 0
/
TennisBall.c
75 lines (61 loc) · 1.31 KB
/
TennisBall.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
#pragma config(Motor, port1, leftMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port5, clawMotor, tmotorVex269, openLoop, reversed)
#pragma config(Motor, port7, armMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, rightMotor, tmotorVex393, openLoop)
short movingForward = false;
void resetMotor() {
motor[rightMotor] = 0;
motor[leftMotor] = 0;
motor[armMotor] = 0;
}
void turn(int waitTime) {
//movingForward = 1;
wait1Msec(1000);
motor[rightMotor] = 0;
motor[leftMotor] = 90;
wait1Msec(waitTime);
resetMotor();
}
void moveArmUp(int waitTime) {
wait1Msec(1000);
motor[armMotor] = 90;
wait1Msec(waitTime);
resetMotor();
}
void moveArmDown(int waitTime) {
wait1Msec(1000);
motor[armMotor] = -90;
wait1Msec(waitTime);
resetMotor();
}
void closeClaw() {
wait1Msec(1000);
motor[clawMotor] = 70;
}
void openClaw() {
wait1Msec(750);
motor[clawMotor] = -70;
wait1Msec(800);
resetMotor();
}
void moveForward(int waitTime) {
movingForward = 1;
wait1Msec(3000);
motor[rightMotor] = 120;
motor[leftMotor] = 120;
wait1Msec(waitTime);
resetMotor();
//movingForward = 0;
}
task main()
{
openClaw();
moveForward(400);
turn()
closeClaw();
moveArmUp(500);
turn(2250);
moveForward(1400);
moveArmDown(300);
openClaw();
}