Page 1 of 1

New to Phidgets - How to Detect Motion and run code using Python?

Posted: Wed Jul 03, 2024 11:41 am
by dbakathaillist
Hello,

I am new to phidgets and would like to know if what I'm envisioning is possible. I would like to use the Motion Sensor connected to a VINT hub, which will connect to my Raspberry Pi. The goal is to make a python script that will play an mp3 in the background once motion has been detected. I am setting up a special event for when the person walks in, they will hear a song played as a special touch. Any examples, tips, or advice on how to accomplish this would be much appreciated.

Re: New to Phidgets - How to Detect Motion and run code using Python?

Posted: Wed Jul 03, 2024 12:46 pm
by LucasP
This guide provides information about getting started with Python and the Raspberry Pi:
This project provides an example of playing a sound based on a Phidget event:

Re: New to Phidgets - How to Detect Motion and run code using Python?

Posted: Wed Jul 03, 2024 12:52 pm
by dbakathaillist
Hello, thank you for your response. But this doesn't really show me how to accomplish what I am trying to do for the motion sensor device. I have a MOT2002_0 motion sensor hooked up to a VINT hub going back to my raspberry pi.

Re: New to Phidgets - How to Detect Motion and run code using Python?

Posted: Thu Jul 04, 2024 1:34 pm
by jdecoux
You can find code samples to get you started in the Code Samples tab for the MOT2002. Simply select your Hub and Python from the drop-down menus. You can adjust the sensitivity of the motion sensor using the sensor type as outlined in the resulting sample.

https://www.phidgets.com/?prodid=710#Tab_Code_Samples

You should be able to put whatever code you use to play sound in the onSensorChange event