There are 4 pir and 1 servo motor and each pir has its own degree. when a pir detect the motion then servo motor rotates to degree of motion but this pir returns to its degree as triggered after the servo motor return to starting point. servo motor makes this situation 2 or 3 times.
is the problem about connection or codes ?
#include <Servo.h>
Servo myservo;
int pin1 = 2;
int pin2 = 4;
int pin3 = 11;
int pos = 0;
int pin4 = 6;
int wait = 1000;
mustafa27:
There are 4 pir and 1 servo motor and each pir has its own degree
So when a PIR goes 'high' the servo should drive to preset position for that PIR?
(what if more than 1 goes high concurrently ??)
mustafa27:
when a pir detect the motion then servo motor rotates to degree of motion
Might help to give us some context and explain what 'the' motion is. You've set specific positions for each PIR, so what does 'degree of motion' mean ? I think I get it from the code, but wouldn't have guessed it without.
mustafa27:
but this pir returns to its degree as triggered after the servo motor return to starting point
'returns' to it's degree ?? 'as triggered' (by itself?) *after * wait, wha .. (?) very confusing
mustafa27:
servo motor makes this situation 2 or 3 times.
that must suck if that's not what you're after - but be great if it is
OK, you might want to consider using a switch/case conditional rather than if/elses ...
Also have a good think about how all those delay(1000)'s are affecting your code - suggestion, maybe place it after all the conditions.
Imagine you're the code - don't miss a step - see where that gets you
1:1:
At the moment the problem is communication ...
So when a PIR goes 'high' the servo should drive to preset position for that PIR?
(what if more than 1 goes high concurrently ??)
Might help to give us some context and explain what 'the' motion is. You've set specific positions for each PIR, so what does 'degree of motion' mean ? I think I get it from the code, but wouldn't have guessed it without.
'returns' to it's degree ?? 'as triggered' (by itself?) *after *wait, wha .. (?) very confusing
that must suck if that's not what you're after - but be great if it is
OK, you might want to consider using a switch/case conditional rather than if/elses ...
Also have a good think about how all those delay(1000)'s are affecting your code - suggestion, maybe place it after all the conditions.
Imagine you're the code - don't miss a step - see where that gets you
I want it to return to the position of the first triggered pir.
Each 4 pir have their own degrees(125,106,68,55).Whichever pir is triggered,then servo motor turns to that direction. pir Looks to only one direction.
Last triggered pir as it is triggered 2 3 times,servo motor returns to its degree.