-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabyrinth.nxc
54 lines (53 loc) · 1.21 KB
/
labyrinth.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
48
49
50
51
52
53
54
int sonar=0;
void backup() {
OnRev(OUT_BC, 50);
Wait(200);
}
void pivotRight(int speed, int time) {
OnFwd(OUT_C, speed);
Wait(time);
Coast(OUT_B);
Coast(OUT_C);
}
task main() {
SetSensorTouch(S1);
SetSensorTouch(S2);
SetSensorLowspeed(S4);
SetSensorLight(IN_3);
bool barva=true;
while (barva) {
OnFwd(OUT_B, 60);
OnFwd(OUT_C, 60);
if(Sensor(IN_3)>53){
Wait(100);
barva=false;
}
if (Sensor(S1) == 1 && Sensor(S2) == 0) {
OnFwd(OUT_B, 20);
}
if (Sensor(S2) == 1 && Sensor(S1) == 0) {
TextOut(0, LCD_LINE1, "sync", true);
OnFwd(OUT_C, 20);
}
if (Sensor(S2) == 1 && Sensor(S1) == 1) {
backup();
pivotRight(50, 500);
Wait(500);
sonar = SensorUS(S4);
Wait(500);
if (sonar < 24) {
TextOut(0, LCD_LINE1, "wrongway");
NumOut(1, LCD_LINE2, sonar);
backup();
Coast(OUT_B);
Coast(OUT_C);
Wait(1000);
//otoceni o 180 stupnu
pivotRight(100, 800);
Coast(OUT_B);
Coast(OUT_C);
Wait(1000);
}
}
}
}