-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdriveCode.c
87 lines (79 loc) · 1.64 KB
/
driveCode.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
#pragma config(Sensor, S1, Gyro, sensorEV3_Gyro)
#pragma config(Sensor, S2, LineTracker1, sensorEV3_Color)
#pragma config(Sensor, S3, LineTracker2, sensorNone)
#pragma config(Motor, motorA, Left, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorB, Right, tmotorEV3_Large, PIDControl, driveRight, encoder)
#pragma config(Motor, motorC, DropMotor, tmotorEV3_Large, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task drop()
{
delay(500);
setMotorSpeed(motorC,25);
}
task rightTurnAfterLine()
{
resetGyro(Gyro);
if(getColorReflected(LineTracker1) == 256 && getColorReflected(LineTracker2) == 256)
{
while(getGyroDegrees(Gyro)<90)
{
setMotorSpeed(Left,50);
setMotorSpeed(Right,-50);
}
}
}
task leftTurnAfterLine()
{
if(getColorReflected(LineTracker1)== 256 & getColorReflected(LineTracker2) == 256)
{
while(getGyroDegrees(S1)<-90)
{
setMotorSpeed(Left,-50);
setMotorSpeed(Right,50);
}
}
task leftTurn()
{
while(getGyroDegrees(Gyro)<-90)
{
setMotorSpeed(Left,-50);
setMotorSpeed(Right,50);
}
}
task rightTurn()
{
while(getGyroDegrees(Gyro)<90)
{
setMotorSpeed(Left,50);
setMotorSpeed(Right,-50);
}
}
task forward()
{
lineTrackLeft(LineTracker1,50,50,100);
}
task BottomLeft()
{
delay(1000);
forward();
}
task BottomMiddle()
{
}
task BottomRight()
{
}
task middleLeft()
{
delay(2000);
forward();
}
task middleMiddle()
{
}
task middleRight()
{
}
task topLeft()
{
}