-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoDumpLeftRamp.c
147 lines (130 loc) · 4.75 KB
/
AutoDumpLeftRamp.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
#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTMotor)
#pragma config(Hubs, S3, HTServo, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, INF, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S3, , sensorI2CMuxController)
#pragma config(Sensor, S4, RGB, sensorCOLORFULL)
#pragma config(Motor, mtr_S1_C1_1, yellow, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_2, red, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, blue, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, green, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, arm, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C3_2, whisk, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C4_1, lift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C4_2, flag, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S3_C1_1, autoflipper, tServoStandard)
#pragma config(Servo, srvo_S3_C1_2, wrist, tServoStandard)
#pragma config(Servo, srvo_S3_C1_3, servo3, tServoNone)
#pragma config(Servo, srvo_S3_C1_4, servo4, tServoNone)
#pragma config(Servo, srvo_S3_C1_5, servo5, tServoNone)
#pragma config(Servo, srvo_S3_C1_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
void driveToInf(){
int a = 5;
int ex = 0;
nMotorEncoder[yellow] = 0;
while(SensorValue[INF] != a && nMotorEncoder[yellow] < 6500){
motor(red) = -80;
motor(yellow) = 60;
motor(green) = -80;
motor(blue) = 60;
if(nMotorEncoder[yellow] < 1000){
a = 5;
ex = 350;
}else if(nMotorEncoder[yellow] < 2000){
a = 5;
ex = 350;
}else{
a = 5;
ex = 50;
}
}
motor(red) = -60;
motor(yellow) = 60;
motor(green) = -60;
motor(blue) = 60;
wait1Msec(ex);
motor(blue) = 0;
motor(green) = 0;
motor(yellow) = 0;
motor(red) = 0;
servo[autoflipper] = 65;
wait1Msec(2500);
servo[autoflipper] = 240;
PlayTone(300,15);
}
void returnto(){
time1[T1] = 0;
while(nMotorEncoder[yellow] > 700 && time1[T1] < 6500){
motor(red) = 60;
motor(yellow) = -60;
motor(green) = 60;
motor(blue) = -60;
}
motor[red] = 0;
motor[yellow] = 0;
motor[green] = 0;
motor[blue] = 0;
}
task blinker(){
while(true){
SensorType[RGB] = sensorCOLORBLUE;
wait10Msec(50);
SensorType[RGB] = sensorCOLORNONE;
wait10Msec(50);
}
}
task main (){
bDisplayDiagnostics=false;
SensorType[RGB] = sensorCOLORRED;
servo[wrist] = 0;
servo[autoflipper] = 240;
eraseDisplay();
nxtDisplayCenteredTextLine(3, "<-- Test Mode");
nxtDisplayCenteredTextLine(2, "Tournament -->");
int waitstart = 0;
while(waitstart == 0){
if(nNxtButtonPressed == 2){
nxtDisplayCenteredTextLine(3, "On test mode");
waitstart = 1;
//test
wait1Msec(1000);
}
if(nNxtButtonPressed == 1){
waitstart = 1;
//tournament
bDisplayDiagnostics = true;
SensorType[RGB] = sensorCOLORBLUE;
waitForStart();
StartTask(blinker);
}
}
motor(red) = -50;
motor(yellow) = -50;
motor(green) = 50;
motor(blue) = 50;
wait1Msec(500);
motor(red) = 0;
motor(yellow) = 0;
motor(blue) = 0;
motor(green) = 0;
servo[autoflipper] = 65;
wait1Msec(2500);
servo[autoflipper] = 240;
PlayTone(300,15);
motor(red) = -60;
motor(yellow) = 50;
motor(green) = -50;
motor(blue) = 60;
wait1Msec(1500);
motor(red) = -50;
motor(yellow) = -50;
motor(green) = 60;
motor(blue) = 60;
wait1Msec(2500);
motor(red) = 0;
motor(yellow) = 0;
motor(blue) = 0;
motor(green) = 0;
}