Command that replaces time.sleep?

0

I'm doing a program that does the detection of color and object formats with a camera, when the format and the color are set, the program controls the GPIOS in which I connected a relay module. The problem I am having is that when I use the time.sleep command to keep the relay module turned on, it causes the entire program to freeze.

Here's the snippet I'm trying to solve:

if len(approx) == 4:    
  gpio.output(40 , 0)
  time.sleep(10)
  gpio.output(40, 1)
  time.sleep(5)
  cv2.putText(frame, "QUADRADO", (x, y), font, 1, (0, 255, 255) )

I'm using opencv and the whole control is done by a Raspberry Pi 3 B +.

Thanks for the attention, friends.

    
asked by anonymous 19.12.2018 / 06:27

1 answer

0

That's how it worked for me, take a look to see if it works.

from time import sleep
print("Faz algo aqui")
##dorme em segundos
sleep(1)
print("Faz outra coisa aqui")
    
19.12.2018 / 12:12