Open paulmunns opened 6 years ago
It's definitely possible, you can run Snowboy in one thread, and run other stuff in another thread.
So i have finally figured it out and its working! But now i have 1 little problem. Im also trying to make the rotation of the motor slower, by the hotword slower.
But the problem is that the motor is not going slower. I have one global variable named D (duty cycle).
When i recall the function MoveUp, only then the new duty cycle is applied and the motor goes slower.
import RPi.GPIO as GPIO import time
D = 50 #dutycycle
def Moveup(pin): global D GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(pin,GPIO.OUT) print("Up") p = GPIO.PWM(pin,100) p.start(0) p.ChangeDutyCycle(D) time.sleep(60) print("Stop")
def Slower(): global D if 0 < D <= 100: D -= 25 print("Slower") else: print("Minimum speed acquired")
So it kinda hard to explain it in 1 sentence but the following thing is what i want to implement. So when you say a hotword, snowboy will detect it and run a script. In this script i will move a motor for a few seconds. While he is executing the script, i want him to continue to listen for another hotword and interrupt the script he was busy with. An example is that i say stop and the motor stops ofcourse. So i was searching for multiprocessing to do this but im kinda new in Python and would like to know if its possible to do what i have in mind.
Any help is welcome.