Пример #1
0
def task2():

    sonic = sensor(21, 20)
    led = LED(19)
    email = EMAIL()

    while True:
        distance = sonic.distance()
        print(distance)
        if distance < 50:
            led.control('on')
            email.send_email()
            time.sleep(60)
            led.control('off')
        time.sleep(1)
def task2(status='off'):  
    
    global interrupt
    
    sonic=sensor(21,20) 
    led=LED(19) 
    led.control(status) 
    
    
    while True:  
        try:
            distance=sonic.distance()   
            print (distance)
            if distance<50:  
                led.control('on')   
                interrupt=1   
                time.sleep(60) 
                led.control(status) 
            time.sleep(1)
         
        except: 
             print ('encountered hardware issue, thread 2 failed')