Command that replaces Team.Leep?

Asked

Viewed 112 times

0

I am making a program that detects colors and shapes of objects with a camera, when being recognized the format and the color configured, the program makes the control of the GPIOS in which I connected a module relay. The problem I’m having is that when I use the time.Sleep command to keep the relay module on, the same causes the entire program to freeze.

Here’s the bit I’m trying to figure out:

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 am using opencv and all control is done by a Raspberry Pi 3 B+.

Thank you for your attention, friends.

  • Official documentation states that the Sleep function(): Suspend execution of the current thread for the given number of seconds. Then you will have to use the multi threading... to use the Sleep function. Or when a microcontroller does not have multi threading, what is used is whether tempo_agora - tempo_inicio/referência == tempo_desejado, then perform such command.

1 answer

0

Guy like that 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")
  • Hello John thanks for your help!!!

  • I made the following commands: from time import Sleep pin_status = gpio.OUTPUT(40, 0) print(pin_status) Sleep(2) #seconds !!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.