jarnelramiscal
Posts: 9
Joined: Sat Mar 03, 2018 8:07 pm

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Wed Mar 07, 2018 9:10 am

sir if i whant the servo he can revers if theres no motion how to put the code

pcmanbob
Posts: 6451
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Wed Mar 07, 2018 11:42 am

The program was written to move the servo to were ever motion was detected and leave it there.

if you want to move the servo to a home position once no motion is detected you would need to change the loop that moves the servo on motion detection, so that if there is no motion the servo is driven to the required position.

So you would need to def a park function with the relevant p.ChangeDutyCycle line in it and any print line you wanted

then you need to change the 2,3,4 if's to elif and add an else: on the end to call the park function.

https://www.tutorialspoint.com/python/p ... f_else.htm
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

madscientist007
Posts: 12
Joined: Fri Jan 26, 2018 5:45 pm

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Wed Apr 04, 2018 1:39 pm

is it possible for someone to try this but using two ultrasonic distance sensor hc-sr04 instead of the PIR. i find the PIR to be very unreliable. thank you.

pcmanbob
Posts: 6451
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Wed Apr 04, 2018 3:43 pm

madscientist007 wrote:
Wed Apr 04, 2018 1:39 pm
is it possible for someone to try this but using two ultrasonic distance sensor hc-sr04 instead of the PIR. i find the PIR to be very unreliable. thank you.
If you want to test this using the HC-SR04 why not do it yourself ?
If I was to test it my environment would be totally different to yours so it may work for me but not you, if you are having problems you need to test in your environment to get any meaningful results.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

seanwang
Posts: 1
Joined: Mon Jul 15, 2019 8:26 am

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Mon Jul 15, 2019 8:30 am

so my project is a automated dust bin and it requires me to me to use one PIR sensor to run a servo motor may i know how should i code it ?

pcmanbob
Posts: 6451
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Mon Jul 15, 2019 9:39 am

seanwang wrote:
Mon Jul 15, 2019 8:30 am
so my project is a automated dust bin and it requires me to me to use one PIR sensor to run a servo motor may i know how should i code it ?
Hi.

There are lots of examples of how to use both the pir and a servo on the pi to be found on the web,

checking the raspberry pi web site would yield examples for both.

https://projects.raspberrypi.org/en/pro ... detector/3

https://projects.raspberrypi.org/en/pro ... a-scarer/4
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
B.Goode
Posts: 8059
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Servo motor control with 4 PIR sensors using Raspberry Pi

Mon Jul 15, 2019 10:02 am

In addition to the resources referred to by @pcmanbob -

The gpiozero library, shipped by default as part of the Raspbian Operating System, has support for both these external devices. It provides a 'toolkit' of software components that can easily be used together.

Motion Sensor 2.17 https://gpiozero.readthedocs.io/en/stab ... ion-sensor

Servo 2.20 https://gpiozero.readthedocs.io/en/stab ... html#servo


(The project resources are probably using these basic components.)

Return to “Python”