Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/tutorial_samples/9_multiple.py
diff options
context:
space:
mode:
Diffstat (limited to 'pynxc/tutorial_samples/9_multiple.py')
-rw-r--r--pynxc/tutorial_samples/9_multiple.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/pynxc/tutorial_samples/9_multiple.py b/pynxc/tutorial_samples/9_multiple.py
new file mode 100644
index 0000000..7ec8aa2
--- /dev/null
+++ b/pynxc/tutorial_samples/9_multiple.py
@@ -0,0 +1,38 @@
+moveMutex=Mutex()
+
+def task_moverandom():
+
+ while True:
+
+ ttt = Random(500) + 40
+ tt2 = Random(1)
+ Acquire(moveMutex)
+ if tt2 > 0:
+ OnRev(OUT_A, 75)
+ OnFwd(OUT_C, 75)
+ Wait(ttt)
+ else:
+ OnRev(OUT_C, 75)
+ OnFwd(OUT_A, 75)
+ Wait(ttt)
+
+ ttt = Random(1500) + 50
+ OnFwd(OUT_AC, 75)
+ Wait(ttt)
+ Release(moveMutex)
+
+def task_submain():
+
+ SetSensorType(IN_1, SENSOR_TYPE_LIGHT);
+ SetSensorMode(IN_1, SENSOR_MODE_RAW);
+ while True:
+
+ if (SENSOR_1 < 100) or (SENSOR_1 > 750):
+ Acquire(moveMutex)
+ OnRev(OUT_AC, 75); Wait(300)
+ Release(moveMutex)
+
+def main():
+ Precedes(task_moverandom, task_submain)
+
+