No video

Using HC-SR501 Motion Sensor with relay and Arduino code to turn ON AC bulb

  Рет қаралды 49,181

Robojax

Robojax

Күн бұрын

This video explains how to control AC bulb or alarm system with HC-SR501 motion sensor using Arduino
I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe.😊
Please like 👍 the video and type simple word in the comment. It helps me a lot.
Get the code and resources for this video: bit.ly/relay-mo...
** Purchase HS-SR501 from **
Amazon USA: amzn.to/3dvyUOm
Amazon Canada: amzn.to/3dy0WJ3
Amazon Europe (All Europe): amzn.to/3dAbkzK
00:00 Start
00:35 Hardware explained
04:35 Relay power rating
06:00 Wiring explained
07:53 Arduino Code Explained
09:48 Demonstration of this project
Tutorial by Ahmad Shamshiri form Canada
****************************
Learn Arduino from a proven instructor with 100s of projects, code, wiring diagram in structured course in one place. Purchase Arduino Course at Udemy.com : robojax.com/L/?...
****************************
If you found this tutorial helpful, please support me so I can continue creating contents like this. Here is PayPal link paypal.me/robo...
Get early access to my videos by becoming my Patreon and and have your name mentioned at end of very videos I publish on KZfaq: robojax.com/L/?...
If you want to learn Arduino from proven instructor on **Udemy**: bit.ly/rj-udemy
Follow me on Facebook robojaxTV
Follow me on Twitter: / robojaxtv
Follow me on Instagram: / robojax
Tutorial by Robojax.com
Get other projects code and learn Arduino
robojax.com/lea...
#robojax #robojax_HC-SR501

Пікірлер: 107
@voiceoftruth1O1
@voiceoftruth1O1 6 жыл бұрын
Another great project. thanks
@adityanathyogi100
@adityanathyogi100 4 жыл бұрын
It can be used to make a sanitizing tunnel for covid 19,just connect pump istead of lamp
@robojax
@robojax 4 жыл бұрын
LOL
@yogeshitaliya473
@yogeshitaliya473 6 жыл бұрын
It's very most use full at home
@barbarasilva675
@barbarasilva675 3 жыл бұрын
Hello, thanks for the video tutorial! I was wondering if you can connect multiple PIR sensors to trigger the same relay? If yes, would you be able to tell me what would be the code line for that? Regards, Fernando
@robojax
@robojax 3 жыл бұрын
Hello, I have explained this line by line and what it does. So if you play the code section 2,3 or more time you should easily understand and turn the same relay on.
@johnathanharris5867
@johnathanharris5867 4 жыл бұрын
thank you very much Gustavo ..
@robojax
@robojax 4 жыл бұрын
You are welcome.
@samhsavdr9647
@samhsavdr9647 6 жыл бұрын
Can you make tesla meter for the number of design wind turbines .. I need it very much and I have a lot of waiting
@bigm8738
@bigm8738 2 жыл бұрын
How would you use a NANO Arduino board it has only 1 x 5V pin out ? Can you simply piggy back from the one pin?
@robojax
@robojax 2 жыл бұрын
Hi, yes you can connect multiple items to the same 5V using a bread board
@Dreamdiariessss
@Dreamdiariessss 3 жыл бұрын
Thanks for support
@saioffice2249
@saioffice2249 5 жыл бұрын
please make a video using 2 or more pir"s with one bulb it will be more helpful to me
@agastyaaneja6569
@agastyaaneja6569 3 жыл бұрын
I can provide you with the code and all the information
@adrianTNT
@adrianTNT 3 жыл бұрын
it should work the same, (connect new sensor's ground and power pins) and just connect the signal to another pin number, and in your code, you test for that pin number too (besides the previous sensor's pin).
@mohamedsalem1640
@mohamedsalem1640 4 жыл бұрын
الله ينور عليك يسطا
@robojax
@robojax 4 жыл бұрын
شکرا و ایا کم.
@Rebius
@Rebius 3 жыл бұрын
Hi, great video. I was just wondering, could you connect the PIR sensor directly to the relay?
@robojax
@robojax 3 жыл бұрын
Hello, yes you can.
@kddayth
@kddayth 2 жыл бұрын
If I wanted to set up four different motion detectors, each to a different color, could I do it all onto the same arduino board or would I need four different boards? For sensing in four different directions.
@robojax
@robojax 2 жыл бұрын
Hello, yes you could.
@ankanupadhyay3616
@ankanupadhyay3616 Жыл бұрын
Can i connect motion sensor and bluetwooth module both at a same time?
@robojax
@robojax Жыл бұрын
Yes you can
@michangela4316
@michangela4316 4 жыл бұрын
nice one
@robojax
@robojax 4 жыл бұрын
Thanks.
@aimandnlll
@aimandnlll 3 жыл бұрын
How about i change a bulb to l298n to move the dcmotor?
@jovanietenebroso5843
@jovanietenebroso5843 3 жыл бұрын
Hi, Can you guys tell me why if the motion is detected, the relay is low and it will turn on?? #respect
@UpSpider
@UpSpider 5 жыл бұрын
Hi Robojax. Amazing videos. I would say that the code would be almost the same if I substitute the motion sensor with a vibration sensor (SW-420 Vibration Sensor ).
@robojax
@robojax 5 жыл бұрын
Hi, Thank you. Yes most sensors work the same way except pins are labeled differently or they are located in different location.
@fairjusticeguy5648
@fairjusticeguy5648 3 жыл бұрын
Hi Robojax. The pir works fine with arduino with your code, however I don't understand why it is 'digitalWrite LOW' to turn on the relay and the opposite to turn off? When I use the pir with the relay running from 5v dc supply (not through arduino)then the light is always on. Do you know why it is like that, looks like the pir doesn't trigger. Thanks
@robojax
@robojax 3 жыл бұрын
Hello, your question took me so long to look at videos and codes to find something even though I have explained it in other multiple videos but see this video 15:44 kzfaq.info/get/bejne/gLNymqqAlZ29fIE.html it is the trigger type. depending on your relay. please don't forget to subscribe. you lose nothing.
@bigm8738
@bigm8738 2 жыл бұрын
Hi Love your video and explanation I would like to simply turn on and off a 5V DC laser light that has a simple on off switch which I would like to control by the Audrino & PIR sensor Can it be done without a relay ? Can you suggest a solution ?
@robojax
@robojax 2 жыл бұрын
Hi, I don't know for what reason you want to avoid using relay but we need a switch to turn ON/OFF the load. If your laser light needs up to 30mA maximum yes you could use Arduino without relay. if you don't like relay, then you can use solid-state switch like mosfet shown here kzfaq.info/get/bejne/Z52mpK-nmpachas.html
@dudehjd
@dudehjd 4 жыл бұрын
Hello, Can you use the power cord from the lightbulb to power the arduino if you step down the voltage? I would like to only use one cable
@robojax
@robojax 4 жыл бұрын
No you can't. AC light bulb is AC and Arduino needs DC .
@shuvamagarwal1769
@shuvamagarwal1769 4 жыл бұрын
can this setup work in a way where the bulb is glowing when there is movement and it gets switched off when there is no movement? basically it should be switched on for the entire time when there is movement instead of giving a timer for 6 sec or 300 sec as you explained in the video. my project is stuck because of this issue. i would be thankful if you can help me out.
@robojax
@robojax 4 жыл бұрын
this will be affected by light.
@shuvamagarwal1769
@shuvamagarwal1769 4 жыл бұрын
what i meant was that instead of getting switched off automatically after few seconds it should get switched off only when there is no movement
@goldenice9283
@goldenice9283 3 жыл бұрын
Hey, great video btw. I used exactly what you used and it works great. I do have some concerns though: is this risky at all? I intend to keep it running 24/7. Will the arduino overheat or the relay have problems ? because I heard the relays tend to fire up frequently on voltage change and such? Do I have to worry? It's inside an electrical box right outside the house with all the components inside that box.
@robojax
@robojax 3 жыл бұрын
Hey, I have not tested the reliability of components. there are tones of different brands producing components. But for Arduino and relay you can add 200mA fuse on the 5V power line so would never allow extra current that might cause fire. Try get relay from Digikey or some other reliable store and make your own module. here is how you can drive a 5V relay using Arduino kzfaq.info/get/bejne/hJOWec5mlqvGaKc.html Arduino itself should be good quality if you purchase Authentic Arduino from Amazon amzn.to/2KApAwK it should be more reliable. Good luck and stay safe.
@goldenice9283
@goldenice9283 3 жыл бұрын
@@robojax Thanks for replying, I'm sorry I'm not really good with these stuff. Does the fuse have to be 200mA? because the least I could find from local stores are 1A. And what exactly causes the fire or what is more risky should I say? the AC 220V on the relay connected to the outlet or the 5V from Arduino?
@goldenice9283
@goldenice9283 3 жыл бұрын
@@robojax I'm using the official Arduino Uno - R3 btw
@robojax
@robojax 3 жыл бұрын
anything I say here will be used against me. This is DIY project. You should know to be careful and take precaution. . Ask a professional to assist you. For myself I trust the relay like I do trust tones of other electronics devices I have. But for you I mentioned the fuse to be safe incase court asks me to come and answer. These relays are used widely in lots of electronic devices.
@Mr_Gadge
@Mr_Gadge 5 жыл бұрын
I wonder if you can help (great video thanks!) I have this sensor but would like a small unit without the arduino. I have it linked with simple single LED and transistor to test. It's working.. but whatever I set the RIGHT wheel for delay to, it keeps randomly lighting with gaps in power. So it will light for 3 seconds, then stop, then light again even though I keep moving it switches off. ?
@robojax
@robojax 5 жыл бұрын
You are welcome. Please watch the video again. There is jumper and two controller. You have experiment and find solution for yourself. The jumper is very important. Have patience and play with it and write down on paper what you did in each step and then compare the results.. this device is very good and it should work for almost any situation. When finding and testing, your single motion will change everything so make sure you sty still if you want no trigger happen.
@Mr_Gadge
@Mr_Gadge 5 жыл бұрын
Robojax I’ve moved jumper. It doesn’t continually light through motion. Just resets. . Many thanks.
@adrianTNT
@adrianTNT 3 жыл бұрын
If you move your hand out and wait for light to stop, then move hand back in, it doesn't lit up, does it ? It has a 4-5 seconds delay to re-trigger? Is that normal ?
@robojax
@robojax 3 жыл бұрын
it should. I have shown how to adjust it. Watch it carefully. There is adjusting and position of object or something.
@rhendemayabanilla6014
@rhendemayabanilla6014 3 жыл бұрын
hello sir! in our project, we have used ADXL335 accelerometer sensor to detect vibrations. We planned to add an automatic light switching using a 5 volts relay. can u please help me out with the codes to interface the accelerometer, relay and arduino to switch on a dc bulb
@robojax
@robojax 3 жыл бұрын
Hello, use you can use the code and this video kzfaq.info/get/bejne/a56Iirl106ibg6c.html good luck
@Giservinworld
@Giservinworld 3 жыл бұрын
Hey I'm a bit confused so I want to ask something, still studying here.. if you connect Relay to normally open, why would you write LOW to turn on the relay? Thank you
@robojax
@robojax 3 жыл бұрын
Hi, perhaps you missed what I've explained. this relay is LOW level trigger. meaning it will turn ON when it receives zero or LOW and turn OFF when it receives 5V or anything about 2V.
@Giservinworld
@Giservinworld 3 жыл бұрын
@@robojax okay thank you very much for the explanation
@shaunferris6063
@shaunferris6063 2 жыл бұрын
HI! great introduction video. still new to Arduino, but how might I go about having 16 relays go on at random times from 1 motion sensor?
@Axel-zg8yc
@Axel-zg8yc 5 жыл бұрын
Hello, Sir. I am interested in hooking up and 8 channel relay with a motion sensor. Do you have a video on that?
@robojax
@robojax 5 жыл бұрын
Hi, I have 4 channel Solid State relay which you can use the Motion sensor with kzfaq.info/get/bejne/aauKmMahzbTIcX0.html
@mejesyoumen1326
@mejesyoumen1326 4 жыл бұрын
Would you please add any buzzer to this circuit
@robojax
@robojax 4 жыл бұрын
This bulb is buzzer, speaker alarm or whatever you want. Light is just example and demonstartion.
@mourisyounan9998
@mourisyounan9998 3 жыл бұрын
Thank you for the vedio . Is there a way to do this motion with the relay without the arduino ? What I want to do is to connect this to a Halloween props and I want the motion to trigger the relay and the relay will be connected to a small motor that will move the props ?!
@robojax
@robojax 3 жыл бұрын
introduction to motion sensor video kzfaq.info/get/bejne/ps-liMl4u8fKc2Q.html and see if the time you can set is enough for your application. then yes you can use it with the relay. The relay shown in this video is LOW Level trigger meaning it turns ON with LOW (or zero volt) level signal. see the high level trigger signal relay kzfaq.info/get/bejne/a56Iirl106ibg6c.html
@mourisyounan9998
@mourisyounan9998 3 жыл бұрын
@@robojax thank you for the reply,but this vedio is for arduino ? What I want is to use the motion sensor with a relay without the arduino ? So is there a relay that can do that or do you have a vedio for that ?
@milanmilicevic4618
@milanmilicevic4618 3 жыл бұрын
So If you want that relay to stay on for 10 seconds you need to increase delay time, but when loop gets to that delay it cant trigger relay because of that delay...
@robojax
@robojax 3 жыл бұрын
first if you want it to stay for 10 seconds, then all other triggers should be ignored. Isn't it? Yes there is solutions. We can use millis() which will not keep the loop waiting. see my two videos in that topic kzfaq.infosearch?query=millis
@Giservinworld
@Giservinworld 3 жыл бұрын
@@robojax so if the motion still there , the relay will always be triggered if millis() is used, right? And that will make the lamp always On?
@chiragbari6202
@chiragbari6202 5 жыл бұрын
How to use 2 pir senser in 1 aurdiuno plz help
@robojax
@robojax 5 жыл бұрын
I will make the video in the future, but you can get the idea from this video kzfaq.info/get/bejne/jbdjoqmqq5vVlY0.html
@ellohemelat8496
@ellohemelat8496 4 жыл бұрын
your tutor is very interested but the code for arduino is not RUN, please say someting
@ellohemelat8496
@ellohemelat8496 4 жыл бұрын
thanks i got it my error, keep it up sir!
@robojax
@robojax 4 жыл бұрын
you are welcome and good luck.
@vasudhas3648
@vasudhas3648 2 жыл бұрын
Hii sir can u help us
@MFAUNIMAP
@MFAUNIMAP 2 жыл бұрын
is it working on uno?
@robojax
@robojax 2 жыл бұрын
Have you see the video?
@MFA8080
@MFA8080 2 жыл бұрын
@@robojax from this vid, this arduino board have 2 5V Pins. but for my board, which is UNO. it only have 1 pin
@robojax
@robojax 2 жыл бұрын
see this video kzfaq.info/get/bejne/pdOpfKmVlqzVc30.html to make additional 5V or GND pins
@rgluisvincentgonzaga4494
@rgluisvincentgonzaga4494 5 жыл бұрын
THE MOTION SENSOR WORKS IN WHAT i DID.. BUT THE GREEN LIGHT ON THE RELAY IS NOT LIGHTING.. THE SAME THING HAPPEN TO MY AC BULB.. WHAT SHOULD I DO TO MAKE THE RELAY WORK SIR
@robojax
@robojax 5 жыл бұрын
check the wiring. Do not modify the code first.
@LeNguyen-yy1qi
@LeNguyen-yy1qi 5 жыл бұрын
You can replace relays with other components
@robojax
@robojax 5 жыл бұрын
Yes you can use any other relay you want. But you need Arduino (any arduino) and the HC-SR501 sensor.
@LeNguyen-yy1qi
@LeNguyen-yy1qi 5 жыл бұрын
@@robojax Ohh... Can you make this circuit in combination with the mechanical switch
@robojax
@robojax 5 жыл бұрын
The possibilities are endless.
@jelbiytube7386
@jelbiytube7386 4 жыл бұрын
hello , what is the Arduino function in that ?
@robojax
@robojax 4 жыл бұрын
you can have time control on how long the light or alarm can be ON or OFF or you can do more thing. This is just opening the opportunity to do more.
@jelbiytube7386
@jelbiytube7386 4 жыл бұрын
@@robojax I need power supply circuit in that , can you help me ? motion sensor with arduino n power supply circuit 🙏
@nursyahidah1663
@nursyahidah1663 3 жыл бұрын
where can i get the coding
@robojax
@robojax 3 жыл бұрын
I mentioned in the first 45 seconds of video. Every video on youTube has description text which is under the video. I have so many important link for the video under the video in the description. Please check it.
@Akhil_Edupuganti
@Akhil_Edupuganti 3 жыл бұрын
Can we set upto 10 minutes?
@robojax
@robojax 3 жыл бұрын
It is just a number you can do even 100 hours
@robojax
@robojax 3 жыл бұрын
No reply? Did you set it to 10 minutes?
@frodemolland6249
@frodemolland6249 2 жыл бұрын
@@robojax where to set f ex 10 minutes? This part : delay(500); ?
@katkurisaivikas2260
@katkurisaivikas2260 4 жыл бұрын
Relay board name
@robojax
@robojax 4 жыл бұрын
I am sorry I did not understand if this is statement or question. If this is question, then the relay module is called "5V Relay module"
@dhruvsingh5087
@dhruvsingh5087 5 жыл бұрын
I have only one 5v port in arduino
@robojax
@robojax 5 жыл бұрын
then in make one of the pin as output. like this in the setup() put this for example pin 5 pinMode(5, OUTPUT); digitalWrite(5,HIGH); and now pin 5 will always be HIGH which is 5V and you can use it as 5V source for small items like relay or sensor.
@johnstonf3506
@johnstonf3506 5 жыл бұрын
@@robojax Please more explanation please
@naveenkoirala9758
@naveenkoirala9758 5 жыл бұрын
@@robojax HI CAN YOU MAIL ME MORE DESCRIPTION ON THIS ONE
@charliekurtantiquera476
@charliekurtantiquera476 4 жыл бұрын
@@robojax you can use female header connect the two 5v to one 5v in arduino right?
@chiragbari6202
@chiragbari6202 5 жыл бұрын
Send me code
@robojax
@robojax 5 жыл бұрын
snag.gy/EG4O2l.jpg and snag.gy/AHhRpV.jpg
@vasudhas3648
@vasudhas3648 2 жыл бұрын
Hii sir can u help us
Trigger DC Motor with PIR Sensor & Arduino - Complete Guide
35:29
Rachel De Barros
Рет қаралды 14 М.
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 25 МЛН
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 127 МЛН
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 37 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 6 МЛН
How to  use HC-SR501 Motion sensor for Arduino with code
8:46
Sensors - which one to use
17:06
Electronoobs
Рет қаралды 1,3 МЛН
Improved Sensors for LED Stair Lighting System
12:54
ResinChem Tech
Рет қаралды 89 М.
Control High Voltage Devices - Arduino Relay Tutorial
7:30
How To Mechatronics
Рет қаралды 632 М.
How to use PIR Motion Sensor with Arduino | Motion sensor light
5:35
hash include electronics
Рет қаралды 96 М.
HC-SR501 PIR motion sensor, easy explained! | #EdisTechlab
12:09
Edi's Techlab
Рет қаралды 12 М.
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 25 МЛН