Go Down

Topic: Servo Motor And PIR (Read 610 times) previous topic - next topic


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;

void setup(){
  pinMode (pin1,INPUT);
  pinMode (pin2,INPUT);
  pinMode (pin3,INPUT);
  pinMode (pin4,INPUT);

void loop (){

  int sensor_1 = digitalRead(pin1);
  int sensor_2 = digitalRead(pin2);
  int sensor_3 = digitalRead(pin3);
  int sensor_4 = digitalRead(pin4);
  if (sensor_1 == HIGH){
 else if (sensor_2 == HIGH){
 else if (sensor_3 == HIGH){
   else if (sensor_4 == HIGH){



Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131