Arduino Controlling Multiple P.I.R Sensor on Same Bord

Introduction: Arduino Controlling Multiple P.I.R Sensor on Same Bord

About: Hye, I am Ajay. & it's all about Electronics and Programming.

Today I will tell you how to connect multiple PIR Sensors with single Arduino Bord

>here i have also used 4 channel relay module for some extra functionality.

ARDUINO + 4 Channel Relay Module + 4 PIR Sensor (OR You can used as many pin your arduino has )

Step 1: Hardware Required

Step 2: Hardware Connection

Arduino________________TO_____________________PIR SENSORS(PIR1,PIR2,PIR3,PIR4)

Arduino PIN 3........................................PIR1-output pin

Arduino PIN 4........................................PIR2-output pin

Arduino PIN 5........................................PIR3-output pin

Arduino PIN 6........................................PIR3-output pin

Arduino 5v..............................................PIR1,PIR2,PIR3,PIR4(VCC )//connect all Vcc pin of pir1, pir2 , pir3 , pir4

//to the Arduino 5 v

Arduino GND..........................................PIR1,PIR2,PIR3,PIR4(GND )

ARDUINO________________TO________________________REALY MODULE

Arduino PIN 9.................................................................IN1 RELAY

Arduino PIN 10.................................................................IN2 RELAY

Arduino PIN 11...............................................................IN3 RELAY

Arduino PIN 12................................................................IN4 RELAY

Arduino GND..................................................................Relay GND

Arduino Vin.....................................................................Relay VCC

12 v -2A Power Supply .................................................to...........................................Relay Model 12v Input &GND (Some Relay Module Does not have 12 v power input so you need a 12 v to 5 v converter ......or you can distribute power by yourself .

Step 3: Programming Part

Here Programming is most important part

while in this project I face lots of problem in programming only.

  • here i have used a Arduino internal pulled up resistor
  • I used (IF-Statement) Without else Statement for stability

If you face any problem do not forget to comment

Be the First to Share

    Recommendations

    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge

    9 Comments

    0
    byron.green.904

    I am trying to connect multiple motion sensors to the same relay with or || signs and it is just leaving the light on. I have If (lightVal<50 && motion3||motion4||motion5||motion6== HIGH)
    digitalWrite(relay, HIGH);
    delay(dv);
    for some reason the light just stays on regardless of motion.

    I also have an else of digitalWrite (relay, LOW);

    0
    michelkeijzers
    michelkeijzers

    1 year ago

    I think you missed one combination, I see 15 and there should be 16 I guess.

    In that case, the code can be simplified using arrays:
    (the alignment is removed by posts sadly, replace ~ by spaces).

    const int NR_OF_MOTION_RELAYS = 4;
    const int MOTION_PINS[NR_OF_MOTION_RELAYS] = { 3, 4, 5, 6 };
    const int RELAY_PINS[NR_OF_MOTION_RELAYS] = { 9, 10, 11, 12 };

    void setup()
    {
    ~~for (int motion_relay = 0; motion_relay < NR_OF_MOTION_RELAYS; motion_relay++)
    ~~{
    ~~~~pinMode(MOTION_PINS[motion_relay], INPUT_PULLUP);
    ~~~~pinMode(RELAY_PINS [motion_relay], OUTPUT);
    ~~}
    }

    void loop()
    {
    ~~for (int motion_relay = 0; motion_relay < NR_OF_MOTION_RELAYS; motion_relay++)
    ~~{
    ~~~~digitalWrite(RELAY_PINS[motion_relay], digitalRead(MOTION_PINS[motion_relay]));
    ~~}
    }

    0
    Leo99
    Leo99

    1 year ago

    Hi, I have a question. I've read your code and I've seen that you did 14 "if cases" in order to control each PIR state. I was wondering if you could replace in the code these 14 structures with 4 if cases written as follow:

    if (proximity1==HIGH){
    digitalWrite(RELAY1, HIGH);
    }
    else{
    digitalWrite (RELAY1, LOW);
    }

    0
    kmutahi
    kmutahi

    1 year ago

    cant see code

    0
    muhammadhishaam583
    muhammadhishaam583

    Question 1 year ago on Step 3

    Hey I want to increase their time, and i don't want to add delay as it pause the program, also not from the PIR delay, is there any other option to increase their time?

    0
    hackplague
    hackplague

    Reply 1 year ago

    Code is in the end.

    2
    jivian111
    jivian111

    Question 3 years ago on Introduction

    How to add buzzer and gsm module for this

    0
    DRNFBN
    DRNFBN

    Answer 1 year ago

    Have you already known how? I also need it for my project