Skip to content

Commit 6b6ddd4

Browse files
committed
Initial commit of etURP
1 parent 6e203aa commit 6b6ddd4

File tree

186 files changed

+28383
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+28383
-0
lines changed

Examples/10_semaphore.nqc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
int sem;
2+
3+
task main()
4+
{
5+
sem = 0;
6+
start move_square;
7+
SetSensor(SENSOR_1,SENSOR_TOUCH);
8+
while (true)
9+
{
10+
if (SENSOR_1 == 1)
11+
{
12+
until (sem == 0); sem = 1;
13+
OnRev(OUT_A+OUT_C); Wait(50);
14+
OnFwd(OUT_A); Wait(85);
15+
sem = 0;
16+
}
17+
}
18+
}
19+
20+
task move_square()
21+
{
22+
while (true)
23+
{
24+
until (sem == 0); sem = 1;
25+
OnFwd(OUT_A+OUT_C);
26+
sem = 0;
27+
Wait(100);
28+
until (sem == 0); sem = 1;
29+
OnRev(OUT_C);
30+
sem = 0;
31+
Wait(85);
32+
}
33+
}

Examples/10_stopping.nqc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
task main()
2+
{
3+
SetSensor(SENSOR_1,SENSOR_TOUCH);
4+
start check_sensors;
5+
start move_square;
6+
}
7+
8+
task move_square()
9+
{
10+
while (true)
11+
{
12+
OnFwd(OUT_A+OUT_C); Wait(100);
13+
OnRev(OUT_C); Wait(85);
14+
}
15+
}
16+
17+
task check_sensors()
18+
{
19+
while (true)
20+
{
21+
if (SENSOR_1 == 1)
22+
{
23+
stop move_square;
24+
OnRev(OUT_A+OUT_C); Wait(50);
25+
OnFwd(OUT_A); Wait(85);
26+
start move_square;
27+
}
28+
}
29+
}

Examples/10_wrong.nqc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
task main()
2+
{
3+
SetSensor(SENSOR_1,SENSOR_TOUCH);
4+
start check_sensors;
5+
while (true)
6+
{
7+
OnFwd(OUT_A+OUT_C); Wait(100);
8+
OnRev(OUT_C); Wait(85);
9+
}
10+
}
11+
12+
task check_sensors()
13+
{
14+
while (true)
15+
{
16+
if (SENSOR_1 == 1)
17+
{
18+
OnRev(OUT_A+OUT_C);
19+
Wait(50);
20+
OnFwd(OUT_A);
21+
Wait(85);
22+
OnFwd(OUT_C);
23+
}
24+
}
25+
}

Examples/11_acknowledge.nqc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
task main()
2+
{
3+
do
4+
{
5+
SendMessage(1);
6+
ClearMessage();
7+
Wait(10);
8+
}
9+
while (Message() != 255);
10+
}

Examples/11_leader.nqc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
task main()
2+
{
3+
ClearMessage();
4+
Wait(200); // make sure all robots are on
5+
Wait(Random(400)); // wait between 0 and 4 seconds
6+
if (Message() > 0) // somebody else was first
7+
{
8+
start slave;
9+
}
10+
else
11+
{
12+
SendMessage(1); // I am the master now
13+
Wait(400); // make sure everybody else knows
14+
start master;
15+
}
16+
}
17+
18+
task master()
19+
{
20+
SendMessage(1); Wait(200);
21+
SendMessage(2); Wait(200);
22+
SendMessage(3);
23+
}
24+
25+
task slave()
26+
{
27+
while (true)
28+
{
29+
ClearMessage();
30+
until (Message() != 0);
31+
if (Message() == 1) {OnFwd(OUT_A+OUT_C);}
32+
if (Message() == 2) {OnRev(OUT_A+OUT_C);}
33+
if (Message() == 3) {Off(OUT_A+OUT_C);}
34+
}
35+
}

Examples/11_master.nqc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
task main() // MASTER
2+
{
3+
SendMessage(1); Wait(200);
4+
SendMessage(2); Wait(200);
5+
SendMessage(3);
6+
}

Examples/11_slave.nqc

1.8 KB
Binary file not shown.

Examples/12_datalog.nqc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
task main()
2+
{
3+
// SetSensor(SENSOR_2,SENSOR_LIGHT);
4+
OnFwd(OUT_A+OUT_C);
5+
CreateDatalog(100);
6+
int x = 0;
7+
int y = 50;
8+
repeat (50)
9+
{
10+
AddToDatalog(x);
11+
AddToDatalog(y);
12+
/*
13+
AddToDatalog(SENSOR_2);
14+
if ((y < 30) && (y > 20))
15+
{
16+
AddToDatalog(SENSOR_1);
17+
}
18+
Wait(20);
19+
*/
20+
x++;
21+
y--;
22+
}
23+
Off(OUT_A+OUT_C);
24+
}

Examples/12_display.nqc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
task main()
2+
{
3+
SelectDisplay(DISPLAY_SENSOR_1); Wait(100); // Input 1
4+
SelectDisplay(DISPLAY_SENSOR_2); Wait(100); // Input 2
5+
SelectDisplay(DISPLAY_SENSOR_3); Wait(100); // Input 3
6+
SelectDisplay(DISPLAY_OUT_A); Wait(100); // Output A
7+
SelectDisplay(DISPLAY_OUT_B); Wait(100); // Output B
8+
SelectDisplay(DISPLAY_OUT_C); Wait(100); // Output C
9+
SelectDisplay(DISPLAY_WATCH); Wait(100); // System clock
10+
}

Examples/12_timers.nqc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
task main()
2+
{
3+
ClearTimer(0);
4+
do
5+
{
6+
OnFwd(OUT_A+OUT_C);
7+
Wait(Random(100));
8+
OnRev(OUT_C);
9+
Wait(Random(100));
10+
}
11+
while (Timer(0)<200);
12+
Off(OUT_A+OUT_C);
13+
}

0 commit comments

Comments
 (0)