0

I am trying to get two things to work at once when the C command is used.

    if command == 'C':
            os.system('aplay /home/pi/sound/cclaw.wav')
            motor = mh.getMotor(3)
            motor.setSpeed(150)
            motor.run(Adafruit_MotorHAT.BACKWARD)
            time.sleep(2.5)

The sound plays then the motor runs. I need the sound to play at the same time as the motor runs

Chris
  • 5
  • 5
  • 4
    Possible duplicate of [How to use threading in Python?](https://stackoverflow.com/questions/2846653/how-to-use-threading-in-python) – Ihor Dobrovolskyi Jul 10 '17 at 09:15
  • 1
    did you try running the command in the background, with `&`? – K. Kirsz Jul 10 '17 at 09:18
  • ive looked at that thread, i do not understand it and it is old. so i know i wont get any response if i ask a question on there – Chris Jul 10 '17 at 09:19
  • no could you please explain, i am learning and am clueless when it comes to this – Chris Jul 10 '17 at 09:20
  • Please use this as a reference [Python - run two commands at the same time](https://stackoverflow.com/questions/25733934/python-run-two-commands-at-the-same-time), Also , I would suggest you use pyMedia for opening your audio file rather than using `os` since the latter is terribly expensive. – Utkarsh Shekhar Jul 10 '17 at 09:20
  • That wouldn't be the right place to ask a question anyway, [so] is for Q+A, not a forum, you should explain on this question why that duplicate didn't help... But having saying that, does running the motor straight after the sound not suffice? I wouldn't imagine much latency there – Sayse Jul 10 '17 at 09:21

0 Answers0