How to Use a PIR Sensor with Arduino: Wiring & Code for Motion-activated Projects

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ค. 2024
  • Dive into the exciting world of interactive projects with my beginner-friendly tutorial on how to use a PIR sensor with an Arduino! Whether you're looking to breathe life into your props, animatronics, or robot projects, this video is your perfect starting point. I break down the essentials of how to connect a PIR sensor to an Arduino, with clear and concise instructions on how to wire a PIR sensor to an Arduino so you get up and running without any hassle.
    But I don't stop at just the basics; this tutorial also dives into practical PIR sensor and Arduino code examples, showing you step-by-step how to program your Arduino to respond to motion. From setting up your PIR sensor to writing your first lines of Arduino code, I've got you covered. By the end of this video, you'll have all the knowledge you need to add motion-activated elements to your projects, making them not only more interactive but also more captivating to your audience.
    So, grab your Arduino and PIR sensor, and let's start making your projects move!
    🔗 Full Tutorial: racheldebarros.com/pir-sensor...
    🔗 Join the Engineering Artists Community: racheldebarros.com/community
    🎬 Video Chapters: PIR Sensor with Arduino Wiring and Code Examples
    0:00 Welcome
    0:21 How Do PIR Sensors Work?
    0:56 Parts of a PIR Sensor
    1:42 PIR Sensor Pinout
    2:04 Time Delay Adjustment Potentiometer
    2:32 Sensitivity Adjustment Potentiometer
    2:57 Trigger Mode Jumper
    4:23 How to Wire a PIR Sensor to an Arduino
    4:59 Reading the Current State of the PIR Sensor Arduino Code
    8:56 Reading the State Change of the PIR Sensor Arduino Code
    13:16 Control an LED with PIR Sensor Arduino Code (using current state)
    14:46 Effect of Time Delay Adjustment on LED
    15:20 Control LED Blink using PIR Sensor Current State
    17:50 Control LED Blink using PIR Sensor on State Change
    19:05 LED Animation: Arduino Code Example 1
    22:45 LED Animation: Arduino Code Example 2
    29:19 Wrap Up
    29:55 Read the Full Tutorial
    30:03 Join the Community
    Build Your Own PIR Sensor and Arduino LED Motion-activated Circuit:
    🛒 PIR Sensor: amzn.to/49CagWn
    🛒 Arduino Uno: amzn.to/48jRlyr
    🛒 Breadboard: amzn.to/42FZZGk
    🛒 Jumper Wires: amzn.to/42K4kbv
    🛒 LEDs: amzn.to/3SIhLV5
    💬 Have any questions or want to share your own experiences, tips and advice about using PIR sensors with Arduino? Drop a comment below - I love hearing from you!
    🔔 If you find this video helpful, please hit that like button 👍 and consider subscribing to my channel for more props/animatronics/robot tutorials, tips, and tricks. Your support helps me create more content like this!
    Some links included here are to affiliate sites. If you purchase something through them, I may earn a small commission - which costs you nothing! I am very grateful for your support when you use my links to make a purchase.
    #arduino #pirsensor #arduinotutorial #arduinocode #props #animatronics
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 44

  • @chvytom
    @chvytom 2 หลายเดือนก่อน +17

    So smart and talented plus absolutely gorgeous ❤

  • @proyectostogo1462
    @proyectostogo1462 2 หลายเดือนก่อน +6

    You are the best 🎉🎉

  • @CryptoRulz
    @CryptoRulz 2 หลายเดือนก่อน +5

    This is great! Watching now. you and hackmakemod are my favorite channels!

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +3

      Thanks for watching! Let me know if you'd like to see a specific topic covered!

  • @lesliefoster9027
    @lesliefoster9027 2 หลายเดือนก่อน +5

    I've just found your channel. It's fantastic. Thank you for leaving the mistakes in.❤❤❤

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +2

      I'm glad you found the channel! I learn the most from my mistakes 🤣

  • @LordHolley
    @LordHolley 2 หลายเดือนก่อน +1

    I love to tinker, so I bought one of those arduino project kits for my son and I to have fun with. It was such a pita to figure out. As a result, it's been collecting dust. You're really taking the mystery out of all of it, and I'm dusting it off and seeing what I can come up with right now. I'm so glad I stumbled across your channel. Thank you!

  • @anubin7625
    @anubin7625 2 หลายเดือนก่อน +3

    This is awesome, I am actually working on an animatronic that can use this. I'm just starting out on Arduino so this is very helpful!

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +1

      Let me know how your animatronic project comes along! I'm doing an entire series on the PIR sensor to control servos, motors and even mp3 players!

  • @scubaken89
    @scubaken89 2 หลายเดือนก่อน +2

    Thanks for explaining things in an easy to understand way. I look forward to the rest of this series.

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +3

      Glad you enjoyed it! I'll be covering how to control servos, motors, and mp3 players soon!

    • @scubaken89
      @scubaken89 2 หลายเดือนก่อน

      Have you ever used ESP32? With ESPNow?

  • @BattleForEden
    @BattleForEden 24 วันที่ผ่านมา

    Wow! So cool! The world is coming aliiiiiiivvvveee

  • @behemoth3562
    @behemoth3562 2 หลายเดือนก่อน +2

    Love the info and how you explain. Simple for me to understand. I’d also like to see how to make random blinking eyes on a prop/mask animatronic. I’ve seen it on instagram but no clear explanation on how they did it on a mask. Thank you 🙏

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +1

      That's a great idea for a future tutorial! For the mask project, one thing you may want to check out is flickering LEDs. They come in red, green, yellow and a variety of different colors. No coding is needed. You just include a resistor and power them with a battery and they flicker randomly on their own. Of course you can program specific patterns with Arduino and trigger them with a PIR sensor too!

    • @behemoth3562
      @behemoth3562 2 หลายเดือนก่อน

      @@RachelDeBarrosLive that’s a cool idea too with blinking LeD’s! But to be more specific; sorry if I wasn’t clear 🙏: blinking eye lids where it looks like the character is shutting and opening eyes. I saw someone build it with a resin printed helmet shell to wear. Which I wonder how they stuck such small components to do that. Thank you so much again!

  • @A_F_Innovate
    @A_F_Innovate 2 หลายเดือนก่อน

    Love your attitude. And the way you presented the material. Keep up the good work.

  • @bwselectronic
    @bwselectronic 2 หลายเดือนก่อน +2

    I've got several Arduinos and haven't taken the time to learn to program them. I think this might get me doing it. I like this video format. No intimidation.

  • @zk_6312
    @zk_6312 หลายเดือนก่อน

    Great video. I have been having trouble with my PIR sensor. Either the LED stays on too long or off too long. I try some of your code to see what went wrong.
    I tried your code and it works better than anyone elses code. Great job.
    One thing though in your 3rd example, the one using the led, you forgot to setup the ledPin as OUTPUT. Not a big deal really, easy to fix, but I thought you might want to know.

  • @michaelgarcia5493
    @michaelgarcia5493 หลายเดือนก่อน

    How that's awsome vid it sounds cool if only I new how to code 🤘🏽😃🤘🏽

  • @kabandajamir9844
    @kabandajamir9844 2 หลายเดือนก่อน

    The world's best Queen teacher thanks

  • @JDude-uj3lk
    @JDude-uj3lk 10 วันที่ผ่านมา

    Rachel, have you ever used hall effect sensors to control a dc motor for movement of a prop to a specific location?

  • @louiepauda6275
    @louiepauda6275 2 หลายเดือนก่อน

    High! Hello, there! Hopefully, all is well! Love you intrest in electronics probably vary technical! Goodluck with all those components!

  • @SummersideDiver
    @SummersideDiver หลายเดือนก่อน

    Awesome presentation style. Informative and engaging way to do these tutorials. Thanks

  • @DBB-KE5DUO
    @DBB-KE5DUO 2 หลายเดือนก่อน +1

    This stream is reminding me I have an acrylic protected motion detector porch light to finish!
    😂😂🤣😢😢😭😭😭

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  2 หลายเดือนก่อน +1

      Noooo - not more projects!!! 🤣

    • @DBB-KE5DUO
      @DBB-KE5DUO 2 หลายเดือนก่อน

      @@RachelDeBarrosLive - Yaaasss! I'll finish one of my many projects someday!
      🤣😂🤣😂

  • @keneflucas937
    @keneflucas937 16 วันที่ผ่านมา

    Hello. I was looking to purchase some of those motion sensors for smart home applications. In the description it says the manufacturer did not install a photodiode. A different one (but looks exactly the same) says photoresistor. Are they the same thing? How will i know if i need to install one? What are the necessary connections for integration?

  • @LonnonFoster
    @LonnonFoster 2 หลายเดือนก่อน

    Great to see that I'm not the only one who does that cringe thing when the sketch is compiling. I'm all "no whammies, no whammies" every single time.

  • @NewAcc02-ok5df
    @NewAcc02-ok5df 18 ชั่วโมงที่ผ่านมา

    Can Arduino simulate keyboard presses? Say I want it to press Crtl+Alt+Delete when the PIR detects motion, is there a command for that?

  • @brucemilyko8549
    @brucemilyko8549 หลายเดือนก่อน

    Just found your Chanel. It's Great! I'm curious, why aren't you using the latest Arduino IDE(2.3.2)?

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  หลายเดือนก่อน +1

      The computer I live stream from isn't the one I usually use for coding so the IDE is waaay outdated. It's on my to-do list to update it so hopefully you'll see the latest one in future videos 👍

  • @brianzimmer1632
    @brianzimmer1632 2 หลายเดือนก่อน

    Gorgeous and Geeky! LOVE LOVE LOVE !!!!

  • @pugxxxmugxxxfootfooot880
    @pugxxxmugxxxfootfooot880 2 หลายเดือนก่อน

    you like to tinker and build things any chance you might build game camera and also maybe have it with wifi ability

  • @shaunewing8973
    @shaunewing8973 2 หลายเดือนก่อน

    your stunning . and great informative videos. 😄😍

  • @alzamamulhaque1613
    @alzamamulhaque1613 2 หลายเดือนก่อน +1

    Please teach me, or help me I have a lot of projects that need some help from experts like you.

  • @Xhilong
    @Xhilong หลายเดือนก่อน

    Is there a way for the Motion Sensor / Arduino to play a mp3 file when it detects motion.

    • @RachelDeBarrosLive
      @RachelDeBarrosLive  หลายเดือนก่อน +1

      It just so happens that I'm about to release another video on just that in about a week or 2! 🥳

  • @jimedgar6789
    @jimedgar6789 2 หลายเดือนก่อน +2

    INTRUDER ALERT! Owld Skew

  • @GoatZilla
    @GoatZilla 2 หลายเดือนก่อน +1

    lol kekeke. perhaps next step would be to switch to an ESP so u can go wireless.
    to start off, the most basic example would be to have the LED follow the inverse of the PIR GPIO. i.e. (pseudocode incoming) digitalWrite(ledPin, ~digitalRead(PIRPin)). That's because the PIR sensors will hold the line high for, what, a second or something, which is long enough to for an eyeball to see the LED, and you don't run into any of your issues. Less is more sometimes.
    second, you should just avoid delays. use rollover safe millis() math instead. Basically almost any time you use delay(), you're probably doing something wrong. This is an unfortunate deficiency in the Arduino ecosystem -- no notion of a "scheduler".
    But basically once you structure the code that way, it's easier to start doing stuff like your fade and other events.