PIR Motion Sensor with Arduino

Поделиться
HTML-код
  • Опубликовано: 31 май 2024
  • hello folks, this video about PIR Motion Sensor and Arduino. With this video, you will learn how to connect PIR sensor with Arduino and program the Arduino to detect any moment in the room or around the motion sensor.
    To make this prototype I am using:-
    Arduino UNO
    PIR Motion Sensor
    Jumper wire
    Breadboard
    PIR module Motion Sensor - Aliexpress
    5Pcs $4.15 - bit.ly/5pcs-SR501-MotionSensor
    1Pcs $0.95 - bit.ly/1Pcs-SR501-MotionSensor
    Arduino UNO - Aliexpress
    Arduino Original $14.80 - bit.ly/ArduinoUNO-original
    Arduino UNO $3.28 - bit.ly/ArduinoUno-smd
    Breadboard - Aliexpress
    1Pcs small Breadboard $1 - bit.ly/Mini-Breadboard
    1Pcs big Breadboard $2.14 - bit.ly/380PointBreadboard
    Mix 120 Jumper Wire $3 - bit.ly/120-mix-Jumper-Wire
    You can find the code on project page, below is the link:
    www.circuitmagic.com/arduino/p...
  • НаукаНаука

Комментарии • 352

  • @brookecox2344
    @brookecox2344 8 лет назад +27

    That was great. Very clear easy to follow video. Nice production quality - good sound and visuals.

    • @Circuitmagic
      @Circuitmagic  8 лет назад +1

      +Brooke Cox Thanks!

    • @onurkyss5183
      @onurkyss5183 7 лет назад +2

      Hi, I am also working a project which is Humanbody speed and direction with PIR. But I want to ask you How can I adjust PIR sensitiviy for human body ? PIR senses all objects heat but I want to PIR sense only HUMAN BODY ? If you answer, I appreciate that. THANKS

  • @sleeth
    @sleeth 5 лет назад +29

    Do you have a video that explains the code in a bit of detail? I'm a bit confused by the takeLowTime and lockLow parts on your website.

  • @rammone5241
    @rammone5241 Год назад +3

    Just what I was looking for, this is a great tutorial, I will definitely put it to use. Thank you so much!

    • @aminamebarki3768
      @aminamebarki3768 3 месяца назад

      I completed it and I want my hand to move. What should I use?

  • @DimitriPerret
    @DimitriPerret 6 лет назад +1

    Great, straight forward, and easy!

  • @normandocherty4207
    @normandocherty4207 4 года назад +2

    Great video, wasn't sure if my PIR was operating, it is!! thanks

  • @user-ov8zx7bv2k
    @user-ov8zx7bv2k 4 года назад +9

    Going to add this into my final year project lol! Thank you!

    • @surajsurya1928
      @surajsurya1928 4 года назад +4

      Your college principle is also watching this😬🤐

  • @cmsbpl
    @cmsbpl 7 лет назад +8

    Thanks, Friend! It worked in one go !

  • @olariksurinta
    @olariksurinta 6 лет назад +3

    Thanks, you made it easy.

  • @rajmahesh9
    @rajmahesh9 6 лет назад +3

    Hi, thank you very much. This is really awesome! I am always wondering how do we convert a quadcopter(drone) into a motion sensor drone. Of course there are lot of models available in the market to buy, but can we do that somehow with Arduino or any other sensor devices ?? Please advice ??

  • @scientistmadhavdasari-9858
    @scientistmadhavdasari-9858 4 месяца назад

    Brilliant Video! Thanks for helping me... I was in a big need.

  • @agstechnicalsupport
    @agstechnicalsupport 4 года назад +1

    Good video briefly explaining how to activate an LED using PIR motion sensor with Arduino. Thank you for posting !

  • @tareknasreldeen6350
    @tareknasreldeen6350 3 года назад +9

    Here is the code guys
    //the time we give the sensor to calibrate (10-60 secs according to the datasheet)
    int calibrationTime = 30;

    //the time when the sensor outputs a low impulse
    long unsigned int lowIn;

    //the amount of milliseconds the sensor has to be low
    //before we assume all motion has stopped
    long unsigned int pause = 5000;

    boolean lockLow = true;
    boolean takeLowTime;

    int pirPin = 3; //the digital pin connected to the PIR sensor's output
    int ledPin = 13;


    /////////////////////////////
    //SETUP
    void setup(){
    Serial.begin(9600);
    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    digitalWrite(pirPin, LOW);

    //give the sensor some time to calibrate
    Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.print(".");
    delay(1000);
    }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
    }

    ////////////////////////////
    //LOOP
    void loop(){

    if(digitalRead(pirPin) == HIGH){
    digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
    if(lockLow){
    //makes sure we wait for a transition to LOW before any further output is made:
    lockLow = false;
    Serial.println("---");
    Serial.print("motion detected at ");
    Serial.print(millis()/1000);
    Serial.println(" sec");
    delay(50);
    }
    takeLowTime = true;
    }

    if(digitalRead(pirPin) == LOW){
    digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state

    if(takeLowTime){
    lowIn = millis(); //save the time of the transition from high to LOW
    takeLowTime = false; //make sure this is only done at the start of a LOW phase
    }
    //if the sensor is low for more than the given pause,
    //we assume that no more motion is going to happen
    if(!lockLow && millis() - lowIn > pause){
    //makes sure this block of code is only executed again after
    //a new motion sequence has been detected
    lockLow = true;
    Serial.print("motion ended at "); //output
    Serial.print((millis() - pause)/1000);
    Serial.println(" sec");
    delay(50);
    }
    }
    }

  • @muhdirfan2272
    @muhdirfan2272 Месяц назад

    Sya dtg sbb Mariposa sruh tngk video nih

  • @nagarjunr4061
    @nagarjunr4061 3 года назад

    Thank you its working good , short vedio with quality content

  • @NageshwarRaoCiliveru
    @NageshwarRaoCiliveru 6 лет назад

    its very helpful and useful. Thanks.

  • @windell8966
    @windell8966 3 месяца назад

    THANK YOU FOR SAVING MY NIGHT

  • @amrzakaria5290
    @amrzakaria5290 5 лет назад

    Easy and Clean , Very Good

  • @nehabhavsar6130
    @nehabhavsar6130 6 лет назад

    great explaintion....very thankful

  • @kt6539
    @kt6539 5 лет назад

    Thanks for the vedio it helped me a lot

  • @electron6807
    @electron6807 6 лет назад

    thanks for making video it is working

  • @opalprestonshirley1700
    @opalprestonshirley1700 7 лет назад

    Great demo. I'm going to get one. Thanks.

  • @gopalkishanpanda6623
    @gopalkishanpanda6623 5 лет назад

    Thanks for my project

  • @herusam04
    @herusam04 6 лет назад +1

    oh thanks, it's work! :D

  • @jamest4198
    @jamest4198 4 года назад

    What can I use to measure and compare vibration levels of different cd players ect? Will the Arduino achieve what I am looking for? How do I get a digital readout to be able to read the vibration level and do comparisons between different sources? Just add a multimeter and some cables to the sensor? If I wanted to measure vibration from the chassis of a cd player, do I just place the Arduino sensor on the cd player?

  • @karimismail3734
    @karimismail3734 7 лет назад

    Great presentation. Will try it soon. Thank you.

  • @thecuriousmindssteamclub
    @thecuriousmindssteamclub 4 года назад +1

    very good quality of explaination

  • @blenvision2308
    @blenvision2308 5 лет назад

    Thanks a lot. Excellent

  • @lifesjustbetterwithcakes3683
    @lifesjustbetterwithcakes3683 4 года назад

    How would I install a 3 way switch with the pir. To where one side runs by motion and other side constant on with middle being off position

  • @user-gp6jn9pb5y
    @user-gp6jn9pb5y Год назад

    Thank you so much!!!!! ✌👏

  • @jackmark868
    @jackmark868 4 года назад

    Circuit Magic rocks🥰🥰

  • @Harshitsamrat
    @Harshitsamrat 5 лет назад +2

    How can we connect 2 sensors like one temperature and one pir and run them sequentially

  • @gulistanproduction6840
    @gulistanproduction6840 5 лет назад

    Thank you So much sir

  • @csunnikrishnan1
    @csunnikrishnan1 5 лет назад +1

    Thank u my friend

  • @nabihahmardhiah240
    @nabihahmardhiah240 7 лет назад

    hye. how to connect pir, arduino uno and gsm SIM900? is it the gsm need power (electricity) or just need to connect all these hardware using jumpwire only?

  • @mohamedkhalilzouitni3803
    @mohamedkhalilzouitni3803 5 лет назад +1

    My PIR motion sensor lacks the little yellow jumper connecting the repeatable/non repeatable trigger. any tips on how to get around this issue would be appreciated :) Thanks!

  • @sritadogiparthi6890
    @sritadogiparthi6890 4 года назад

    Helped me in the last minuit of my project!!! Thanks a lot...

    • @fero___3005
      @fero___3005 4 года назад +1

      how to download the code..? in website

  • @aaroncatolico7550
    @aaroncatolico7550 Год назад

    Are these particular sensors good for outside motion detection lights?

  • @bennetsharwin6185
    @bennetsharwin6185 3 года назад

    thank you but can we use LCD instead of using serial monitor

  • @menasheaharonian9183
    @menasheaharonian9183 3 года назад +5

    Hey
    Very nice explanation.
    A. Will the pir manage to sense a fly?
    B. Is the sensing influenced by surrounding temperature?
    Thanks

  • @celine93wong
    @celine93wong 7 лет назад

    Would it be possible to replace the LED with a seven segment display instead?How would the coding change too?>

  • @baileytaylor6731
    @baileytaylor6731 6 лет назад

    Mostly this won't be seen but would that thing turn be able to enable a button to be pressed so say if the sensor wasn't waved the button won't work but when you wave it it will worm

  • @michaelchiaravalloti7197
    @michaelchiaravalloti7197 3 года назад +1

    Is there any way to get the PIR sensor to send something like a notification to my phone or computer rather than activating an LED?

  • @GadgetCentral
    @GadgetCentral 5 лет назад

    Hey what if i wanted to turn this into a baby monitor? For example i'd like to install the sensor in baby's room and the led indicator light in my garage. Is there a way to do this wirelessly instead dragging a long wire from babys room the garage?

  • @kddayth
    @kddayth 2 года назад

    Would it be possible to set up four different motion sensors to four different color lights onto the same board?
    For motion sensing in four different directions. Or would I need to set up four separate projects?

  • @mekapatidarshanik6788
    @mekapatidarshanik6788 4 года назад +1

    Great work and explanation. This might seem like a beginner question, since I'm a beginner. But can we connect output pin of pir sensor to analog pin rather than digital pin.
    Thank you.

    • @rekhaagarwal9694
      @rekhaagarwal9694 4 года назад

      Pir sensor gives digital output so u need to connect it to digital pin.
      ruclips.net/video/4NWowu5wghM/видео.html

    • @mekapatidarshanik6788
      @mekapatidarshanik6788 4 года назад

      @@rekhaagarwal9694thank you I figured it out. I just soldered output to adafruit L293d digital pin2 and also vcc and GND to L293d. Works fine.

  • @dawa-hdeh8681
    @dawa-hdeh8681 Год назад

    thank you very much

  • @lanadelrae8470
    @lanadelrae8470 2 года назад +6

    i hate school man

  • @efeoktay244
    @efeoktay244 5 лет назад

    very nice thanks

  • @frodemolland6249
    @frodemolland6249 6 лет назад

    Hi, is this possible to add to a arduino clock somehow? It runs on battery and I would like it to turn off, when no one is in the room and on when there is people in the room

  • @thatoniondude
    @thatoniondude 5 лет назад

    I know this video has been uploaded quite a while ago, but is it possible for the output to have a camera snap a picture? Asking for a friend.

  • @rayhanparvez2131
    @rayhanparvez2131 5 лет назад

    Thank you

  • @DSASecurity
    @DSASecurity 3 года назад

    The issue i have with the pir sensors is when i throw a large object like a karton box in front of it , it detects movememt.
    So the PiR works as a motion sensor and not specificly as a PIR SENSOR.
    How can i change it as s human detector and not as a lifeless karton box detector ?
    Any ideas?

  • @ramuacharya1254
    @ramuacharya1254 4 года назад

    I want to make project something like:
    There are two door in my room and i want to turn on fan automatically when any no. Of person stay in my room.
    And turn off automaticall when no one is at room.
    Can it be made using pir sensor only??

  • @orhan_erdem
    @orhan_erdem 6 лет назад

    Clearly stated and shown. Thanks @circuitmagic

  • @velveetynn
    @velveetynn 9 месяцев назад

    hi. may i ask what should i change if i want to make the led light stays on for 5 mins?

  • @hasch8348
    @hasch8348 2 года назад

    I'm pretty much a beginner so this might be a silly question but how could I add a pushbutton to this?

  • @koffin9236
    @koffin9236 7 лет назад

    Thanks

  • @nicholasgraham89
    @nicholasgraham89 7 лет назад +1

    Awesome! I am new to Arduino, and only took a couple of minutes to knock out. Here's a question, is there a way to display the actual time of sensor violation in the serial monitor? Thanks for the information!

    • @JooshYT
      @JooshYT 2 года назад +1

      You will need a RTC module, or connect to a network and use NTP to get the current time.

  • @Kostanj42
    @Kostanj42 5 лет назад +5

    you can just make it like this:
    int state;
    void setup() {
    pinMode(A0, 0);
    pinMode(13,1);
    while(state == 1) { //this while loop is for waiting until pir is calibrated
    state = digitalRead(A0);
    delay(1000);
    }
    }
    void loop() { //just put the value of pir as the led state(when pir detects movement the output is high, so the led is high too)
    state = digitalRead(A0);
    digitalWrite(13, state);
    delay(1000);
    }
    it's very simple and it works perfectly for me. Otherwise you could use a transistor to switch the led with 10k base resistor. also pin 13 NEEDS a resistor for the led. there is a resistor on pin13 but it's for onboard led and it doesn't effect the output pin.

  • @SanukaSenumitha
    @SanukaSenumitha 3 года назад

    super excellent

  • @the_nguy9123
    @the_nguy9123 6 лет назад +13

    I would highly recommend everyone to wire a 220ohm resistor with the led to prolong the life of the led bulb.

    • @Circuitmagic
      @Circuitmagic  6 лет назад +1

      Thanks for your suggestion

    • @AtlantaTerry
      @AtlantaTerry 6 лет назад

      Isn't PIN #13 on an Arduino the same as the built-in LED? If so, it might already be protected.

    • @leonardolai1994
      @leonardolai1994 5 лет назад +1

      No, there is no "hidden" built-in resistor in pin #13, so you're basically plugging your led between Vcc and ground. It still works because of the internal voltage drop of the led, also pins are limited in current. However, that way you're absorbing more current than necessary (you see the led is very bright), thus shortening the life of the bulb.

    • @Isomodsfordays
      @Isomodsfordays 5 лет назад

      Leonardo Lai yeah because those LED’s are incredibly expensive right? No it doesn’t really matter the board does indeed have a built in resistance when plugging in an LED to pin 13 and ground

    • @leonardolai1994
      @leonardolai1994 5 лет назад +8

      LEDs' price is absolutely irrelevant here, and I never mentioned it. Of course they're extremely cheap, but why would you want to learn electronics (which is the main purpose of Arduino) the wrong way, just because these components are almost free to replace? Moreover, if you start neglecting the value of resistors (in terms of usefulness, not price), then you are likely to fry a 200$ sensor if ever working on a real-world system. If you get used to best practices since the beginning, your life will be easier later.

  • @yacinehefied7390
    @yacinehefied7390 4 года назад

    hi can u explain me why sometimes detects movement even if I haven't done anything?

  • @shalimarphotocenter7194
    @shalimarphotocenter7194 3 года назад

    Very good

  • @sanjanaperna6624
    @sanjanaperna6624 3 года назад

    can we measure the distance of the moving object using pir sensor ? plz reply

  • @anelson1914
    @anelson1914 Год назад

    I plan on using this in some corn hole boards with LEDs.

  • @MrNams
    @MrNams 3 года назад +2

    My hc-sr501 gives always high output, what is issue?

  • @executeorder6667
    @executeorder6667 2 года назад

    Would I be able to link it up to a speaker or something along those lines and get a robot voice to say Intruder or something has entered the room

  • @riossnn
    @riossnn 4 года назад +1

    dang 10/10 vid tho

  • @diyoregonnowtexas9202
    @diyoregonnowtexas9202 2 года назад

    I have a perimeter alert system I like, but the company is out of
    business so I cant get more sensors from them. There is a base unit that
    has 6 channels for up to 6 motion sensors,but I only have one. How can I
    make a motion sensor from a different security system work with this
    one, so I can add it to my system?

  • @neilsumanth8013
    @neilsumanth8013 5 лет назад +6

    excellent work...But could you please explain coding for this in arduino software.

    • @mohammedyasarshaikh4090
      @mohammedyasarshaikh4090 3 года назад

      yea, the program is written like a paragraph and also no setup is placed as serial begin is placed above loop, looks like author not wants to copy the concept, thank you

    • @neilsumanth8013
      @neilsumanth8013 3 года назад

      @@mohammedyasarshaikh4090 Got it, I sorted it out, Thank you.

  • @woolfy02
    @woolfy02 Год назад +2

    Is it possible to trigger something with more power, instead of a LED?( Maybe something like 5-12 volts.)

    • @nevis2769
      @nevis2769 4 месяца назад +1

      Yes. Use a pwm signal to a logic level shifter to drive a high voltage load such as a motor

  • @pythonbylearning8467
    @pythonbylearning8467 4 года назад

    Nice one

  • @kichu6598
    @kichu6598 3 года назад

    hlo sir what we want to do for light is on more than 1 minutes (if it is possible when we increase the delay in program code )

  • @alexreizas5948
    @alexreizas5948 7 лет назад +4

    Instead of LED, can I turn on 5v battery operated device? Would I need a relay?

    • @xgamerbih
      @xgamerbih 6 лет назад +2

      Yes you can do whatever you want... A relay is the best idea to do high voltage and amp stuff. You just need to edit the code so it turns the relay on/off whenever the sensor detects something. It's a simple IF function

  • @aravindkrishna6133
    @aravindkrishna6133 7 лет назад +5

    which potentio meter is used to adjust the tine of on and off

    • @tadiniteriad8093
      @tadiniteriad8093 6 лет назад +2

      There are two on the sensor itself. Two orange wheels. Those are the potentiometers : One for the time, the other for the distance. Check the sensor's datasheet for more details.

    • @not_aly_ashraf
      @not_aly_ashraf 6 лет назад

      thx

    • @MG-ko3rz
      @MG-ko3rz 5 лет назад

      one on right side

    • @k1rv0lak
      @k1rv0lak 5 лет назад

      @@MG-ko3rz No.

  • @robertonagel2102
    @robertonagel2102 5 лет назад

    can you make it so that the light stays on the amount of time someone is detected by the sensor?

  • @yahiamohamed4833
    @yahiamohamed4833 5 лет назад

    how to make the LED switch off when the PIR sensor detect another movement .. not after 15 seconds ?

  • @markoguberinic2279
    @markoguberinic2279 7 лет назад

    Could you explain how to wire the same thing as in this tutorial, but if I wanted to have 3 x PIR Sensors? The idea is that if one of the sensors detect movement, the light switches on. Thanks.

    • @AtlantaTerry
      @AtlantaTerry 6 лет назад

      Try this: tie three different outputs from the Arduino to one input of a relay.
      When activated, the relay will turn on the light. Relays are available for 110v and 220v lights. Google: Sonoff

  • @ashishkakne
    @ashishkakne 5 лет назад

    Hello sir, can u please suggest code for Send IR sensor data to live server(database)?

  • @SamratDutta
    @SamratDutta 7 лет назад

    Thank you sir for your help but can you help me out in my idea of the new project where i want to make my home door to open automatically when someones comes infront of it using the pir sensor and the arduino. If you want to help then sir please send me the code for arduino and the schematic .Thank you.

  • @CBGsavagePoop
    @CBGsavagePoop 4 года назад

    are there any alternatives for the LED

  • @lloydguia3118
    @lloydguia3118 4 года назад

    Hello what if i used 12v LED? what module i use? thanks

  • @AOBAboOmer
    @AOBAboOmer 7 лет назад

    I like I need more project about , sensor fire

  • @adrianpineda2955
    @adrianpineda2955 Год назад

    Thankyou.

  • @MomentofEngineering
    @MomentofEngineering 8 лет назад

    can i use an IR module instead of PIR sensor?

  • @omkarmandavkar6808
    @omkarmandavkar6808 2 года назад

    Hey, I followed your each n every step but my LED is taking more than 2 min to turn OFF after motion detection, can you please suggest a solution on it ??

  • @safugam
    @safugam 8 лет назад

    Hi can i on led only 1ms or 500 micros ?? I mean not 15s , i need help

  • @tmctrulymathsclasses296
    @tmctrulymathsclasses296 5 лет назад +1

    Sir, I make this same project without aurdino and it's really work and delay time is 5 to 6 second

  • @JobQuestUnveiled
    @JobQuestUnveiled 7 лет назад +22

    I am sorry but mine is blinking no matter there is an object or not!

    • @venomouspancake9917
      @venomouspancake9917 6 лет назад +2

      Henri A SAME HERE!!!!!!!

    • @danielmeursing1552
      @danielmeursing1552 6 лет назад +1

      That jeans the code is nog correctly saved because the blinking is the standart program

    • @hemantsinghbohra9720
      @hemantsinghbohra9720 6 лет назад +1

      your code is not working

    • @FarSeeker8
      @FarSeeker8 6 лет назад

      Try covering the sensor with something that blocks IR/heat radiation. Like the silver mylar wrapper of a
      candy bar. There may be unknown heat sources triggering it.

    • @NovaTechnologies
      @NovaTechnologies 6 лет назад +1

      Hi everybody! It is a common thing, simply the sensor is damaged!!! I had two sensors one is damaged and one is not. Same code working with one and not with the damaged one.

  • @TheGroundsman2024
    @TheGroundsman2024 2 года назад

    Can you add wled to this as it uses a data wire

  • @angelzenelaj
    @angelzenelaj 3 года назад +1

    how do you upload the code on to Arduino Editor?

  • @parz2353
    @parz2353 3 года назад

    If I connect a battery to this do I need to leave it plugged in ?

  • @amarsamuh
    @amarsamuh 4 года назад

    can it using with arduino leonardo ?

  • @maddiek9
    @maddiek9 Год назад

    Where is the power input? can it be a battery or does it have to be hard-wired?

  • @chrisivardsouza1623
    @chrisivardsouza1623 4 года назад

    Can i use pir in sunlight

  • @paulu3732
    @paulu3732 3 года назад

    Hi, how to Set the sensor to off once there is no movement . I don’t want 15s or 20s

  • @WhiteBuzzardP
    @WhiteBuzzardP 3 года назад

    Hi, does anyone know how to figure out which pin i which? I just have a sensor with 3 pins

  • @sundararajann6007
    @sundararajann6007 5 лет назад

    this module can directly drive a led no need for audrino.

  • @NURULAINUMAIRAHBINTIROSL-rk3kv
    @NURULAINUMAIRAHBINTIROSL-rk3kv 9 месяцев назад

    How do I make the led last for like 40 seconds before it goes off?

  • @MathewZ788
    @MathewZ788 4 года назад

    thanks man thought my circuit was garbage but my pir to start with was faulty