Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/tutorial_samples/9_multiple.py
blob: 7ec8aa2cc4476ce8c30dc8869f170e0f81d03c01 (plain)
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
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)