How to use PIR Motion Sensor with Arduino | Motion sensor light

Поділитися
Вставка
  • Опубліковано 22 лип 2024
  • In this video we are going to learn how to use PIR motion Sensor (HC-SR501) with Arduino so that we can detect if there is any human movement and take some action.
    We will make a motion switch to turn on and off light automatically if human motion is detected.
    I have explained in details each step along with code and connections.
    👉Please subscribe: ua-cam.com/users/hashinclude...
    👉Components list :
    ✅ Arduino Uno amzn.to/3tjKRMR
    ✅ PIR Sensor module amzn.to/3qgxAUj
    ✅ 5V Relay amzn.to/3pWsr2u
    ✅ AC bulb socket and plug
    ✅ Blub
    ✅ 7-12 V DC battery
    ✅ Breadboard
    ✅ Jumper wires
    👉 Shorts Channel :
    / ujwalnandanwar
    👉Code and diagram:
    github.com/un0038998/lessons/...
    👉What is Relay and how to use it
    • What is Relay? | How t...
    👉Watch more videos:
    / hashincludeelectronics
    👉Follow us on Instagram:
    / hashincludeelectronics
    #pirsensor #hashincludeelectronics #arduino
  • Наука та технологія

КОМЕНТАРІ • 127

  • @rajannachandnkera6892
    @rajannachandnkera6892 Рік тому +3

    I want know who to use hw-416-b model pir sensor

  • @ujwalskill9592
    @ujwalskill9592 6 місяців тому +5

    thank you so much .this project is working

  • @cylexarts3598
    @cylexarts3598 Рік тому +1

    Slight problem, after 10 secs of activation it just turns off even thougj im moving in front of the sensor...how to fix this?

  • @crispinopesalbon6663
    @crispinopesalbon6663 2 роки тому +1

    thanks bro it works

  • @al-ustad2428
    @al-ustad2428 20 днів тому +1

    Thanks for helping...🎉

  • @taefm9712
    @taefm9712 Рік тому +2

    can you connect the arduino with thingspeak platform to analysis the data from the sensor and who it does?

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому +1

      I believe thingspeak needs internet and Arduino can not handle that . You need to use modules like esp32

  • @memphistomem3576
    @memphistomem3576 9 місяців тому +1

    Hi, I just did this one here, works perfect :) But I just wonder how to make light stay on until I leave the room? Is it just to set pir sensor to HIGH mode?

    • @hashincludeelectronics
      @hashincludeelectronics  9 місяців тому

      Thank you very much for checking out the video and nice comment 👍🏻👏🏻. It will stay high as long as you are there in the room and keeps moving .

  • @Raja-dl5uc
    @Raja-dl5uc 7 місяців тому +1

    thanks for the code

  • @chandandas647
    @chandandas647 7 місяців тому +1

    You have single channel relay
    Was used. If I am using a 2 channel relay then where should I put the input of the second relay.
    I have to connect 2 bulbs

  • @Raja-dl5uc
    @Raja-dl5uc 7 місяців тому +2

    thanks
    i am a 13 year old boy
    i was searching for guidance for my science expo
    ur project made my way clear

    • @hashincludeelectronics
      @hashincludeelectronics  7 місяців тому

      I am glad that you liked the video and it was helpful to you. Keep learning and I wish you all the best for your future 👏🏻👏🏻👍🏻

  • @4ri8
    @4ri8 Рік тому +1

    but i can also connect the output pin of PIR to relay input pin directly without using arduino right?

  • @ayoraz_0144
    @ayoraz_0144 Рік тому +3

    uhhh so i have a question: how can i use the 2 normal rgb leds with 4 pins on this project?

    • @ted_van_loon
      @ted_van_loon 15 днів тому

      what do you want them to do?
      if you use a arduino you can just program the arduino to the the special colour effect and colour changing and such.
      otherwise you can use some transistors or mosfets or some IC's like counters to program in the animation and do it without a arduino.
      if you plan to litterally use it in a fixed colour then you can just connect them all to the same output with resistors for every led pin. you might want to use a transistor however since the GPIO of a arduino or the pir sensor depending on which one you use, might not deliver enough current for all 6 leds.
      essentially a 4 pin RGB led, are just 3 different leds in one casing. one of the pins is often ground, which is typically shared between them the others are the input for the 3 leds. in some cases the one pin connected to all leds might be the + pin and the other pins might be - so either test it or read the datasheet to find out. to test it, just connect 2 jumperwires to the arduino, one to +5v and one to gnd. also connect a resistor to one of the jumper wires with a resistance value of around 500 to 1000 Ohm, it might not be needed and you can use lower values, but this is for safety to not accidentally fry a led when testing. then just test pin combinations and you will see which pin is what colour and what direction, etc.
      also note that you do not need to use the arduino
      the arduino is litterally just used as a transistor to amplify the signal so you can just use a transistor and 1(or optimally 2) resistors to do the same, next to that the arduino is used as a 5V power suply. but the module supports 5v to 20v. so you can also power it by some 12v or 5v adapter or such, or even from a usb port. other values in between 5v and 20v also work, but if you use a relays to switch the light then make sure it supports the used voltage as driving voltage, which is why 5v and 12v are usefull since they are commonly used.
      also please be aware that while it supports up to 20V you typically do not want to run it at 20V, while it should not be a problem, since it is always running, typically when such devices support up to 20V it is still best to just use 5v or 12v. not only are they more standardized values, but driving it at 20V might be driving the buildin step down converter to it's limit. since it essentially takes your input voltage and uses a step down converter to reduce it to around 3.3V next to that it might also convert something to 5V but not certain of that. but the output signals are 3.3V.
      it uses very low power however, so it shouldn't give problems, but still if something runs always you are best of making sure it is really safe, and durable.

  • @pinkbrush5543
    @pinkbrush5543 9 місяців тому +1

    Hello. Im actually beginner and I have a project to do. I need to control alot of servo motor (12) with motion sensor and at the same time I have to control another thing (kind of robot with arduino). I want to use IR control and motion sensor for the first robot, also with the data flow and the other robot to move simultaneously

    • @hashincludeelectronics
      @hashincludeelectronics  9 місяців тому +1

      This looks like big project . I would suggest to go through my tutorial videos on servo , sensors etc and see if it helps 👍🏻👏🏻

  • @shabnambhadauria3009
    @shabnambhadauria3009 10 місяців тому +1

    Can i add a voice assistant to this project, and if yes and then how, do you have a video on it , kindly share ,it would helpful

    • @hashincludeelectronics
      @hashincludeelectronics  10 місяців тому

      This is very basic project and we can not add voice assistant as it is . 👏🏻👍🏻

  • @HappyHermitt
    @HappyHermitt Рік тому +2

    I would like to use a servo with a pir. Could this code be edited for it?

  • @The.Real.Reddit.Chronicles
    @The.Real.Reddit.Chronicles Рік тому +3

    did you cut the plug wire yourself? and where can i find a AC Bulb socket like yours?

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому +1

      Yes you can cut the wires as needed . Also you can buy the sockets which are available at your location . No issues in that . 👍🏻 but make sure to make proper connection as it deals with AC voltages .

    • @ritika7665
      @ritika7665 2 місяці тому

      ​@@hashincludeelectronicscould u give the link on where I can buy ac plug socket like that

  • @user-qo6pt8hk3b
    @user-qo6pt8hk3b 2 місяці тому +1

    Awesome

  • @cylexarts3598
    @cylexarts3598 Рік тому +1

    What if you are using 2 motion sensors, does that mean you need to use 2 arduino's....and also can this design be use in a 16mhz arduino?

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому +1

      You will have to use only 1 Arduino . Yes it will work for 16mhz Arduino . 👍🏻

    • @rajaramrr
      @rajaramrr Рік тому +1

      Actually you don't even need an Arduino, you can directly connect the output of the PIR sensor to trigger the relay. But it's a very nice tutorial though 👏

  • @kundan.rajput
    @kundan.rajput 3 місяці тому +1

    Hello , I want to ask one thing
    I have a 5v relay module and 1 pir sensor
    I have done connection
    Vcc of sensor and relay are from same charger of 5v 1A
    Gnd pin is also same
    Out of sensor is connected to in of relay
    And relay's No is connected to bulb and common is connected to vcc
    I am facing the issue
    Bulb is always onn after power on supply
    Even after it for not detect human

    • @hashincludeelectronics
      @hashincludeelectronics  3 місяці тому

      Please check the video slowly and carefully for missing steps 👍🏻👏🏻

  • @Dinaltium
    @Dinaltium 7 місяців тому +4

    Hey bro, I am a beginner into coding ( I know a bit of Python coding but not C) So can you give me code to adjust the timing for the light to stay on, Mines stay on for a minute or 2 and then switches of after that. Since I need this for my upcoming project exhibition, I want it to switch off faster so I can show again quickly how my project works instead of having to wait for long

    • @ted_van_loon
      @ted_van_loon 15 днів тому

      this sensor is meant for being used directly without microcontroller so there directly is a knob for adjusting it on the board, the code in the video does nothing more than read the value and copy it to another pin, see 1:23 in the video how to adjust it.
      since the sensor does a lot already it is slightly harder to use but still easy. so here is what code you would ask for
      #define SENSOR_PIN 2
      #define RELAY_PIN 3
      void setup() {
      pinMode(SENSOR_PIN, INPUT);
      pinMode(RELAY_PIN, OUTPUT);
      }
      bool on = false;
      int ontime = 1000; //1000 is 1 second
      void loop() {
      if (digitalRead(SENSOR_PIN) == HIGH) {
      if (!on) {
      on = true;
      digitalWrite(RELAY_PIN, LOW);//this1
      delay(ontime);
      digitalWrite(RELAY_PIN, HIGH);//this2
      }
      } else {
      on = false;
      }
      }
      //you might want to change the HIGH and LOW at this1 and this2.
      //if you alter int ontime then you change the time it stays on, 1000 miliseconds is 1 second. since the module itself can already go down to 3 seconds, I took 1 second now.

  • @RenzAndreiSuarez
    @RenzAndreiSuarez 4 місяці тому +1

    can i ask about the jumper cable what pin is that is that 10 pin?

  • @user-cx1tm8ii2x
    @user-cx1tm8ii2x 9 місяців тому +1

    Can you give the link for 7-12 V DC battery as well?

    • @hashincludeelectronics
      @hashincludeelectronics  9 місяців тому

      Yes. You can check my other car videos where I have provided the battery link 👍🏻👏🏻

  • @prabhatverma7538
    @prabhatverma7538 3 роки тому +1

    Awesome 👍...

  • @propanda5584
    @propanda5584 10 місяців тому +2

    Bro can you tell what is the advantage of using aurduino UNO instead of doing it directly?

    • @hashincludeelectronics
      @hashincludeelectronics  10 місяців тому +2

      You can add any additional handling using Arduino code . You can add delays etc . 👍🏻👏🏻

  • @ManuelJarvinALuna
    @ManuelJarvinALuna 17 днів тому +1

    can i make it send me a message or a call whenever a motion is detected?

  • @brianmasangkay9153
    @brianmasangkay9153 Рік тому +1

    where we can buy the battery? what is other replacement for it

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому

      You can buy it online on Amazon . You can use lion batteries as well . But make sure you use rechargeable battery only .

  • @lancedias9333
    @lancedias9333 2 роки тому +2

    In the circuit diagram why isnt the breadboard included?

    • @hashincludeelectronics
      @hashincludeelectronics  2 роки тому +1

      Thanks for checking out the video and for query . Breadboard is just for extending the connections. So i did not include in circuit diagram to keep the connections clear with modules. I hope you are familiar with how to use breadboard . Let me know if you need any help .

  • @ronixbhaskar8263
    @ronixbhaskar8263 Рік тому +2

    How to connect the arduino code on the proteus software

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому +1

      Unfortunately I don’t have any idea on that . Please share your findings 👏🏻

  • @jpena6678
    @jpena6678 8 місяців тому +1

    Well I have another question. The light is turning on while motion is detected but turning off immediately. How do I keep it lighting?

    • @hashincludeelectronics
      @hashincludeelectronics  8 місяців тому

      How long do you want the light to be turned on ? You can add that in code as well 👍🏻👏🏻

    • @jpena6678
      @jpena6678 8 місяців тому

      @@hashincludeelectronics My idea is to just turning the light on then I would manually turn it off.

  • @furqonoof
    @furqonoof 7 місяців тому +1

    how do i make the project doesnt require battery?

  • @animeghost_7
    @animeghost_7 12 днів тому +1

    can i use dc plug direct to the home switch port

    • @hashincludeelectronics
      @hashincludeelectronics  11 днів тому

      Sorry I did not understand your point 👍🏻👏🏻

    • @animeghost_7
      @animeghost_7 11 днів тому

      @@hashincludeelectronics can i provide dc supply on both sides

  • @_Literallyus
    @_Literallyus 5 місяців тому +1

    How can i use this project for industrial automation

    • @hashincludeelectronics
      @hashincludeelectronics  5 місяців тому +1

      You can use this wherever you need to take some action based on human movements . Do some research where this can be used 👍🏻👏🏻

    • @_Literallyus
      @_Literallyus 5 місяців тому

      @@hashincludeelectronics Thankyou indeed !!

  • @user-zw6ns6yx4x
    @user-zw6ns6yx4x 5 місяців тому +1

    Will it still work if I replace the bulb with a mini fan?

    • @user-zw6ns6yx4x
      @user-zw6ns6yx4x 5 місяців тому +2

      Also will the code still work if I already replaced the bulb with a fan?

    • @hashincludeelectronics
      @hashincludeelectronics  5 місяців тому +1

      It will work 👍🏻👏🏻

  • @magnese7993
    @magnese7993 Місяць тому +1

    I don't know coding but I know if an else bu I didn't understand the Hi and low???

    • @hashincludeelectronics
      @hashincludeelectronics  Місяць тому +1

      High and low is Notting but voltage level. High means 5v and low means 0 volt 👍🏻👏🏻

    • @magnese7993
      @magnese7993 Місяць тому +1

      @@hashincludeelectronics Thanks can we built it on the cell and no connected with laptop and on and off switch just like a small box and portable.

    • @hashincludeelectronics
      @hashincludeelectronics  Місяць тому

      @@magnese7993 yes you can 👍🏻👏🏻

  • @ZenHulk
    @ZenHulk 6 місяців тому +3

    This set yp is like playing with legos in the 70sm blah, never works, those sensors sell 5 at a time because 3 dont work or work sometimes in the best condition on your bench.

  • @mohamadaldawood4949
    @mohamadaldawood4949 2 роки тому +1

    Is there a problem using 220 volt electricity?

    • @hashincludeelectronics
      @hashincludeelectronics  2 роки тому

      Thanks for checking out video 👍 There is no problem in using 220 V in this project . However good care should be taken while making connections as we are dealing with AC High Voltage. So make sure you connect wires properly. You can check my other video for reference where I have explained how to use relay. Let me know if you face any issue .

    • @mohamadaldawood4949
      @mohamadaldawood4949 2 роки тому +1

      @@hashincludeelectronicsCan I have a video link?

  • @artoflivingrajkot
    @artoflivingrajkot 9 місяців тому +2

    will it work on my project which is street lights made from LEDs?

    • @hashincludeelectronics
      @hashincludeelectronics  9 місяців тому +1

      It should work 👍🏻👏🏻 However take good care while making this project as we are dealing with AC at the output 👍🏻

    • @artoflivingrajkot
      @artoflivingrajkot 9 місяців тому +2

      @@hashincludeelectronics can you tell me what to use instead of AC bulb socket? Or can I directly connect the wires of LED to arduino UNO?

    • @hashincludeelectronics
      @hashincludeelectronics  9 місяців тому +1

      @@artoflivingrajkot how many LEDs are there ? Is it like a series of LEDs?if these LED bulbs are AC controlled then instead of bulb socket you can use normal plug socket and use it . 👍🏻

    • @artoflivingrajkot
      @artoflivingrajkot 9 місяців тому +2

      @@hashincludeelectronics there are 12 LEDs.and it is not LED bulbs they are 5mm LED diodes.that's why I asked you that it will work or not.

    • @artoflivingrajkot
      @artoflivingrajkot 9 місяців тому +2

      @@hashincludeelectronics sir i will want 9v battery in it so how to insert the positive and negative wires and from where in the relay or arduino i will get the output? please tell me sir tomorrow is my science fair.

  • @riddhi2509
    @riddhi2509 3 місяці тому +1

    Breadboard of how much dots?? 80 or 100

  • @jpena6678
    @jpena6678 8 місяців тому +1

    I didnt understand where you used the Battery? is it not necessary?

    • @hashincludeelectronics
      @hashincludeelectronics  8 місяців тому +1

      Yes we have used battery . Please check the video and also circuit diagram for reference 👍🏻👏🏻

    • @jpena6678
      @jpena6678 8 місяців тому

      @@hashincludeelectronics thanks for replying. yeah I found that

  • @mayuritekar6793
    @mayuritekar6793 7 місяців тому +1

    Can we supply 12v DC power in place of 220v Ac

    • @hashincludeelectronics
      @hashincludeelectronics  6 місяців тому +1

      Yes you can but you will have to use 12c dc appliance then 👍🏻👏🏻

    • @mayuritekar6793
      @mayuritekar6793 6 місяців тому +1

      @@hashincludeelectronics what are those appliances

    • @hashincludeelectronics
      @hashincludeelectronics  6 місяців тому

      @@mayuritekar6793 I am not sure . As you want to use 12v dc instead of 220v ac 😂

    • @mayuritekar6793
      @mayuritekar6793 6 місяців тому +1

      @@hashincludeelectronics no bro.. I have 12v DC solar system, so I want to run entire motion sensor on 12v. Please suggest me bro😥⁦🙏🏻⁩

    • @hashincludeelectronics
      @hashincludeelectronics  6 місяців тому +1

      @@mayuritekar6793 you can connect it to Arduino vin pin directly then 👍🏻👏🏻

  • @shahnewajbd4623
    @shahnewajbd4623 8 місяців тому +1

    How can we use your link for diagram and code

    • @hashincludeelectronics
      @hashincludeelectronics  8 місяців тому

      You can download the code and diagram from that link and use it 👏🏻👍🏻

    • @shahnewajbd4623
      @shahnewajbd4623 8 місяців тому +1

      @@hashincludeelectronics i can't see any download options in there

    • @hashincludeelectronics
      @hashincludeelectronics  8 місяців тому

      @@shahnewajbd4623 click on the link . Then it will open something where the code and diagram will be there . Please explore 👏🏻👍🏻

    • @shahnewajbd4623
      @shahnewajbd4623 8 місяців тому +1

      @@hashincludeelectronics thanks you very much

  • @aathik7229
    @aathik7229 11 місяців тому +1

    One doubt, It is consider as AI Project?

  • @biviyu3828
    @biviyu3828 Рік тому

    Yo, i have a problem with this, can you help me please?

    • @hashincludeelectronics
      @hashincludeelectronics  Рік тому

      What problem are you facing. ?

    • @biviyu3828
      @biviyu3828 Рік тому

      @@hashincludeelectronics my sensor is keep detecting things even though everything around it are standing still

  • @ShubhamKumar-pj6es
    @ShubhamKumar-pj6es 6 місяців тому +1

    Code wala link open nahi ho Raha hai

  • @talhamalik36699
    @talhamalik36699 4 місяці тому +1

    Please give programming

    • @hashincludeelectronics
      @hashincludeelectronics  4 місяці тому

      Code and diagram link is provided in the description of the video 👏🏻👍🏻

  • @mohaiminrahman6592
    @mohaiminrahman6592 Рік тому +2

    Everytime of light on and off,I hear the sound of switch😁

  • @SumanSuman-lq1vg
    @SumanSuman-lq1vg 10 місяців тому +1

    Aap sahi se code btao

    • @hashincludeelectronics
      @hashincludeelectronics  10 місяців тому

      The code and diagram link is provided in the description of the video 👍🏻👏🏻

    • @SumanSuman-lq1vg
      @SumanSuman-lq1vg 10 місяців тому

      @@hashincludeelectronics hamne try kiya but kuch ni ho rha ... plz help kijye

  • @AyeshanidaNuheen-rj3lb
    @AyeshanidaNuheen-rj3lb Рік тому

    Switch off on

  • @clobel55
    @clobel55 11 місяців тому +1

    speak english!!!!!!!!!!

  • @g42vaishnavihr73
    @g42vaishnavihr73 16 днів тому +1

    Hello brother thank you for the project it was working first but then the relay green light is blinking continuously started and the red color in relay is on and the bulb is just sparking please provide your email id so i can send you the sample