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... - Наука
That was great. Very clear easy to follow video. Nice production quality - good sound and visuals.
+Brooke Cox Thanks!
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
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.
Just what I was looking for, this is a great tutorial, I will definitely put it to use. Thank you so much!
I completed it and I want my hand to move. What should I use?
Great, straight forward, and easy!
Great video, wasn't sure if my PIR was operating, it is!! thanks
Going to add this into my final year project lol! Thank you!
Your college principle is also watching this😬🤐
Thanks, Friend! It worked in one go !
Thanks, you made it easy.
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 ??
Brilliant Video! Thanks for helping me... I was in a big need.
Good video briefly explaining how to activate an LED using PIR motion sensor with Arduino. Thank you for posting !
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);
}
}
}
I FKN LOVE YOU
the comment section is lucky to have you :)
Sya dtg sbb Mariposa sruh tngk video nih
Thank you its working good , short vedio with quality content
its very helpful and useful. Thanks.
THANK YOU FOR SAVING MY NIGHT
Easy and Clean , Very Good
great explaintion....very thankful
Thanks for the vedio it helped me a lot
thanks for making video it is working
Great demo. I'm going to get one. Thanks.
Thanks for my project
oh thanks, it's work! :D
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?
Great presentation. Will try it soon. Thank you.
very good quality of explaination
Thanks a lot. Excellent
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
Thank you so much!!!!! ✌👏
Circuit Magic rocks🥰🥰
How can we connect 2 sensors like one temperature and one pir and run them sequentially
Thank you So much sir
Thank u my friend
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?
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!
Helped me in the last minuit of my project!!! Thanks a lot...
how to download the code..? in website
Are these particular sensors good for outside motion detection lights?
thank you but can we use LCD instead of using serial monitor
Hey
Very nice explanation.
A. Will the pir manage to sense a fly?
B. Is the sensing influenced by surrounding temperature?
Thanks
A. Yes
B. No
Would it be possible to replace the LED with a seven segment display instead?How would the coding change too?>
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
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?
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?
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?
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.
Pir sensor gives digital output so u need to connect it to digital pin.
ruclips.net/video/4NWowu5wghM/видео.html
@@rekhaagarwal9694thank you I figured it out. I just soldered output to adafruit L293d digital pin2 and also vcc and GND to L293d. Works fine.
thank you very much
i hate school man
very nice thanks
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
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.
Thank you
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?
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??
Clearly stated and shown. Thanks @circuitmagic
hi. may i ask what should i change if i want to make the led light stays on for 5 mins?
I'm pretty much a beginner so this might be a silly question but how could I add a pushbutton to this?
Thanks
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!
You will need a RTC module, or connect to a network and use NTP to get the current time.
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.
super excellent
I would highly recommend everyone to wire a 220ohm resistor with the led to prolong the life of the led bulb.
Thanks for your suggestion
Isn't PIN #13 on an Arduino the same as the built-in LED? If so, it might already be protected.
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.
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
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.
hi can u explain me why sometimes detects movement even if I haven't done anything?
Very good
can we measure the distance of the moving object using pir sensor ? plz reply
I plan on using this in some corn hole boards with LEDs.
My hc-sr501 gives always high output, what is issue?
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
dang 10/10 vid tho
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?
excellent work...But could you please explain coding for this in arduino software.
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
@@mohammedyasarshaikh4090 Got it, I sorted it out, Thank you.
Is it possible to trigger something with more power, instead of a LED?( Maybe something like 5-12 volts.)
Yes. Use a pwm signal to a logic level shifter to drive a high voltage load such as a motor
Nice one
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 )
Instead of LED, can I turn on 5v battery operated device? Would I need a relay?
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
which potentio meter is used to adjust the tine of on and off
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.
thx
one on right side
@@MG-ko3rz No.
can you make it so that the light stays on the amount of time someone is detected by the sensor?
how to make the LED switch off when the PIR sensor detect another movement .. not after 15 seconds ?
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.
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
Hello sir, can u please suggest code for Send IR sensor data to live server(database)?
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.
are there any alternatives for the LED
Hello what if i used 12v LED? what module i use? thanks
I like I need more project about , sensor fire
Thankyou.
can i use an IR module instead of PIR sensor?
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 ??
Hi can i on led only 1ms or 500 micros ?? I mean not 15s , i need help
Sir, I make this same project without aurdino and it's really work and delay time is 5 to 6 second
how without arduino
I am sorry but mine is blinking no matter there is an object or not!
Henri A SAME HERE!!!!!!!
That jeans the code is nog correctly saved because the blinking is the standart program
your code is not working
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.
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.
Can you add wled to this as it uses a data wire
how do you upload the code on to Arduino Editor?
If I connect a battery to this do I need to leave it plugged in ?
can it using with arduino leonardo ?
Where is the power input? can it be a battery or does it have to be hard-wired?
Can i use pir in sunlight
Hi, how to Set the sensor to off once there is no movement . I don’t want 15s or 20s
Hi, does anyone know how to figure out which pin i which? I just have a sensor with 3 pins
this module can directly drive a led no need for audrino.
How do I make the led last for like 40 seconds before it goes off?
thanks man thought my circuit was garbage but my pir to start with was faulty