-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlag.nxc
47 lines (45 loc) · 888 Bytes
/
Flag.nxc
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
#define SPEED 40
#define CorrectHigh 65
#define CorrectLow 5
int timer;
task main()
{
OnFwd(OUT_AC, 70);
Wait(10);
SetSensorLight(IN_3);
SetSensorColorFull(IN_1);
OnFwd(OUT_AC, SPEED);
while(true)
{
/* Following is pseudo code
if (MOTOR ROTATION > DEGREES)
{
break;
}
Feel free to implement it if you want */
if (Sensor(IN_1) == 6)
{
OnFwd(OUT_C, CorrectHigh);
OnFwd(OUT_A, CorrectLow);
until(Sensor(IN_3) > 38)
}
else if (Sensor(IN_3) > 38)
{
OnFwd(OUT_A, (CorrectHigh + 10));
OnFwd(OUT_C, CorrectLow);
until(Sensor(IN_1) == 6)
}
else
{
OnFwd(OUT_AC, SPEED);
}
}
// Commands to be executed, however the while loop is not broken
// pseudo code is implemented
Off(OUT_AC);
// Turn Motor 90 (our gearing means that the second value isn't 90)
RotateMotor(OUT_A,100,150);
OnFwd(OUT_A, 55);
OnFwd(OUT_C, 50);
Wait(1000);
}