Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/tutorial_samples/10_mutex.py
blob: 25994b4ac817da2eb27fa24985b07b2eea7d072a (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
moveMutex=Mutex()

def task_move_square():

    while True:
        Acquire(moveMutex)
        OnFwd(OUT_AC, 75); Wait(1000)
        OnRev(OUT_C, 75); Wait(850)
        Release(moveMutex)

def task_check_sensors():

    while True:
        if SENSOR_1 == 1:
        
            Acquire(moveMutex)
            OnRev(OUT_AC, 75); Wait(500)
            OnFwd(OUT_A, 75); Wait(850)
            Release(moveMutex)
            
def main():
    SetSensor(IN_1,SENSOR_TOUCH)
    Precedes(task_check_sensors, task_move_square)