Trigger DC Motor with PIR Sensor & Arduino - Complete Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ค. 2024
  • Welcome to my comprehensive Arduino tutorial where I'll show you step by step, how to use a PIR sensor to turn on a DC motor using an Arduino Uno. From wiring each component to an Arduino Uno, to writing a variety of Arduino code examples from scratch, you'll be able to build your own motion-activated DC motor project and control it with Arduino and a PIR sensor.
    Whether you're building an automated gadget, an interactive art installation, or a Halloween motorized prop that comes alive when someone walks by, turning on a DC motor with a PIR motion sensor is a useful Arduino project for a lot of applications.
    🔗 Full Tutorial: racheldebarros.com/turn-on-dc...
    🛠🎨 Join my Engineering Artists Discord Community for LIVE WORKSHOPS & COMMUNITY BUILDS (Zoom) ▶︎ racheldebarros.com/community
    BUILD YOUR OWN Motion-activated DC Motor with PIR Sensor and Arduino:
    🛒 PIR Sensor: amzn.to/49CagWn
    🛒 Arduino Uno: amzn.to/48jRlyr
    🛒 12V DC Motor: amzn.to/43kjiWj
    🛒 XY-160D Motor Driver Module: amzn.to/3vbrPOr
    🛒 12V 5A Power Supply: amzn.to/48UfMD5
    🛒 Female DC Jack Adapter: amzn.to/4aa8pZd
    🛒 Breadboard: amzn.to/42FZZGk
    🛒 Jumper Wires: amzn.to/42K4kbv
    🎬 VIDEO CHAPTERS: Motion-activated DC Motor with Arduino Wiring & Code
    0:00 Welcome
    0:40 PIR Sensor Time Delay, Sensitivity & Trigger Mode
    1:51 PIR Sensor Pinout
    2:22 Wire a PIR Sensor to Arduino Uno
    3:10 Wire a DC Motor to Arduino Uno
    7:43 Arduino Code: Test PIR Sensor
    14:01 Arduino Code: Spin Motor with PIR Sensor
    19:17: Arduino Code: Spin Motor in Opposite Direction
    19:46 Arduino Code: DC Motor Minimum PWM value
    21:29 Arduino Code: PIR Current State vs. State Change
    24:44 Arduino Code: Turn Motor in Both Direction with PIR Sensor
    26:59 Arduino Code: Accelerate & Decelerate Motor with PIR Sensor
    33:55 Wrap Up
    34:06 Get Full Tutorial with Code
    35:04 Join the Community
    💬 Have any questions or want to share your own experiences, tips and advice about using a PIR sensor to turn on a DC motor 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 #dcmotor #motors #arduinotutorial #arduinocode #arduinoproject #props #animatronics
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    I have learned more from the way you teach this than anyone else online, better than all my Stanford instructors back a decade ago. Now I'm rewatching all your other videos.

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

    You couldn’t have timed this video any better. I mean really! I’m teaching myself how to use an Arduino. My first motor driver was just delivered today. I’ll be doing this tomorrow. Go get yourself a cookie!

  • @Holly-ku8vz
    @Holly-ku8vz หลายเดือนก่อน +5

    Thanks for this really well detailed video and for links to each component!

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

      No problem! Hopefully it takes some of the guess work out 👍

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

    It doesn't get any better than a new video from you. Thank-you!

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

    Thank you Rachel.

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

    Really impressed by this informative and practical tutorial video!😃Looking foward to having more potential working possibility with u

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

    PLEASE KEEP DOING I LIKE WIPER MOTOR SUCH KING OF TUTORIAL

  • @AEMIROBAYEH
    @AEMIROBAYEH 29 วันที่ผ่านมา

    you are really a genius please do wiper or servo motor control using rain detection sensor based on real-time rain intensity for windshield wiper system control?

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

    I like this video a lot. 🥳 Smart girls rock. Thank you.

  • @Jondon-hm7nh
    @Jondon-hm7nh หลายเดือนก่อน

    good stuff. Perfect guidance

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

    I haven't used a pir yet cool video😁

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

    Another great teaching video. Maybe you or one of your other followers can help me. I am working on a greenhouse project and I am trying to figure out how to timestamp when the water meter (hall effect) sensor starts and stops counting.

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

    Thanks!🎉

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

    This is a great lesson. I learned a lot. Have you tried to use the park feature of the wiper motor maybe wired on the second side of the motor controller. I was thinking of a popup prop and then park as return to start.

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

      That's a great idea! I've only used the park feature with a switch so far and not with the Arduino.

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

    Hey Rachel . Would love to see some guide from you based on hoverboards. They are dirt cheap and easy for ppl to get. Comes with motors, batteries and reusable logicboards. For example a RC skateboard or mower ? Cheers

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

      That's a great idea! There are lots of good things to harvest off them.

    • @jstro-hobbytech
      @jstro-hobbytech หลายเดือนก่อน

      ​@@RachelDeBarrosLivewhere I live they have heavy garbage pickup in the spring and there's hoverboards, games consoles, stereos and so much needless waste. I fix the stuff or repurpose and give it away. I live in a rural area so there's no danger poking around.

  • @TheOldKid
    @TheOldKid 12 วันที่ผ่านมา

    A question for anyone. I was using an l293d as dual h-bridge running a mg996r servo and a motor from a powerwheels grave digger with flysky. Worked fine until smoke and fire. I realized later one of the wires from my main voltage supply had broke loose and shorted across the l293d. I ordered the same driver Rachael uses in this video and cannot seem to get it to work. The l293d had EN1&2 , 5v, input 1&2, output 1&2 and main power input. The xy160d has same type pin labels. The only thing that i see possibly different is l293d has EN1&2 the xy160d has PWM1 on docs where board says EN.
    Arduino pins 5&6 went to input 2&7 on l293d and arduino 9 went to transmitter.
    Could it be that with the new board i need a pwm signal from the arduino to the EN/PWN on the driver along with another pin from arduino to transmitter?
    Im no programmer by any stretch. Im a fabricator and welder. I can imagine to everyone in the microcontroller world this is a simple no brainer but im old, melt metal. If i cant straighten it with a sledge hammer or welder i have a torch. This is the last piece to my puzzle to have my project operational so all help, any help or advice is greatly appreciated

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

    I`ve just made a garage alarm using the same PIR sensor. I tested it for a week and got one false reading. Might of been the sun light coming through a window. I`ve added a 10k ohm pull down resistor to the 5 volt signal just in case that caused it. I also use a window screen wiper motor to pull an insulated cover over in the greenhouse to keep the plants warm at night and keep the lighting right. :)

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

      How has the PIR sensor worked since you put on the resistor? I love your greenhouse cover idea too - great project!

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

      @@RachelDeBarrosLive It`s worked ok this week. But it` moved out the Sun too. I was worried it would go off in the night and wake up the neighbours.:)

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

      Here is my code for a garage alarm with a magnetic door sensor and PIR. Had to use a PI Pico with the Arduino IDE in the end due to the Arduino stopped connecting. :)
      int n=0;
      int alarm_mode=0;
      int door=0;
      int on_off=0;
      int pir=0;
      int exit_time=0;
      int entry_time=0;
      int intruder=0;
      int alarm_time=0;
      void setup() {
      pinMode(8, INPUT); // ON/OFF SWITCH
      pinMode(9, OUTPUT); // BUZZER
      pinMode(10, INPUT); // DOOR MAGNETIC SWITCH
      pinMode(11, INPUT); // PIR SENSOR
      pinMode(12, OUTPUT); // ALARM RELAY
      pinMode(13, OUTPUT); // LED
      digitalWrite(9, LOW); // SET BUZZER LOW = OFF
      digitalWrite(12, LOW); // ALARM RELAY DEFAULT HIGH = OFF
      digitalWrite(13, LOW); //SET THE LED LOW = OFF
      delay(1000);
      }
      void loop() {
      on_off=digitalRead(8);
      delay(4);
      door=digitalRead(10);
      delay(4);
      pir=digitalRead(11);
      intruder=0;
      if(pir == HIGH){
      intruder=1;
      }
      if(door == LOW){
      intruder=1;
      }
      if (intruder == 0){digitalWrite(13, LOW);}
      if (intruder == 1){digitalWrite(13, HIGH);}
      if (on_off == LOW){
      alarm_mode=0;
      digitalWrite(12, LOW);
      noTone(9);
      }
      if (alarm_mode == 0 && on_off == HIGH){
      alarm_mode=1;
      exit_time=6000; // 60 seconds
      }
      if (alarm_mode == 1){ // ALARM SET AND WAITING 60 SECONDS TO GET OUT.
      exit_time=exit_time-1;
      if (n==0){tone(9, 1000);}
      if (n==20){noTone(9);}
      if (exit_time == 0){
      alarm_mode=2;
      }
      }
      if (alarm_mode == 2){ // ALARM SET. WAITING FOR AN INTRUDER.
      noTone(9);
      if (intruder == 1){
      alarm_mode=3;
      entry_time=3000; // 30 seconds
      }
      }
      if (alarm_mode ==3){ // Coming into the garage and the alarm enter timer is activated.
      if (n==0){tone(9, 800);}
      if (n==50){noTone(9);}
      entry_time=entry_time-1;
      if (entry_time == 0){
      alarm_mode=4;
      alarm_time=1000;
      }
      }
      if (alarm_mode == 4){
      noTone(9);
      digitalWrite(12, HIGH); // ALARM RELAY ACTIVATED.
      alarm_time=alarm_time-1;
      if (alarm_time == 0){
      digitalWrite(12, LOW);
      alarm_mode=5;
      }
      }
      if (alarm_mode ==5){ // Alarm has been activated and now warns me of an intruder has been in.
      if (n==0){tone(9, 1500);}
      if (n==5){noTone(9);}
      }
      n=n+1;
      if(n >= 100){
      n=0;
      }
      delay(2);
      }

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

    I have a question for you about an electrical board and also Mopars. Where is a good place to message you ?

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

    Hello, I've a question. In many wiring schemes I see online, the xy160d is also powering the Arduino itself. I can't get that to work. Have i misunderstood something

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

    If Bill and Ted's kids had coding/engineering kids, you would be that awesome thing ❤

  • @user-hr5dc4ly3q
    @user-hr5dc4ly3q หลายเดือนก่อน

    Hi i hope you are fine .. when i use relay and arduino and i2c LCD relay even contain diod the spike inside relay let LCD become freeze if you know to solve this problem tell me

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

    CAN BE USE WITH ANY KIND OF DC MOTOR?

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

    Hello, is it possible to make a tutorial to make the dc motor run with sensor but without arduino or any other materials ?

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

    Hey, I am going to be building auto doors for my smallish shelf unit. I now have 2 ideas as to how i would like to do it, after seeing this video. I watched a video on using a 2 button idea and thought that would be fantastic but, now i am thinking 2 pir's or motion sensors. i have not drawn up any plans at the moment as i went through some medical things. I do like to play with led lights strips and have them nearly everywhere in my room lol. Is there any chance you might be able to do a tutorial on making something like that Pretty Please ?
    And Yes, i have to agree, this tutorial was awesome as.

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

      I can definitely do one on controlling an LED strip with Arduino so you can program some cool lighting animations!

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

      @@RachelDeBarrosLive, I was actually talking about the sensors for the auto door open and closing. I have already succeeded in doing the led light strip with the addressable strips using youtube videos on that subject. Thankyou a whole heap though. I just read my comment i put up lmao, that question at the end was supposed to be at the end of when i was talking about the auto doors for my cupboard (silly me). So i do apologise for that.

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

    Negelet any negative comment plese keep doing

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

    Hi, are you aware of the "auto format" tool in the IDE?

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

      Thanks for letting me know! 👍 I also need to update the IDE to the latest version 🤦‍♀️😆

    • @g3-is-me
      @g3-is-me หลายเดือนก่อน

      @@RachelDeBarrosLiveDon't remove the old IDE when you install the new one. There are sometimes incompatibilities on the new version. Just stumbled on your channel today. I'm enjoying these!

  • @Suzukii-Krypto
    @Suzukii-Krypto หลายเดือนก่อน

    Love the new Eyewear in this video, well new to me since this is the 2nd video of yours I'm watching, this time, with my 10-year-old son and sometimes my 8-year-old daughter.
    You're so Easy to learn from and (rudely stare at). Stoooooop!!
    Why couldn't you be a scary, semi-balding, cock-eyed old evil Scientist?
    (Kidding of course)😅😂

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

    My ghost friend (Tesla) just told me about Bluetooth power 😂 -
    the downside is it constantly makes that motor whining noise 🤣

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

    Who else is here just because Rachel is so damn easy on the eyes!!!!!!!??????

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

      She looks like she could be my old girl friends kid.

    • @TheOldKid
      @TheOldKid 12 วันที่ผ่านมา

      End up watching multiple times because she tends to pull attention off components. Oh well. It helps view counts.

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

    too many mistakes in the video

    • @jstro-hobbytech
      @jstro-hobbytech หลายเดือนก่อน

      I think it's meant to be fun brother. Great for kids and people with just an arduino kit. The code is verbose as anything but it's not an enterprise level deployment haha. Cheers

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

      @@jstro-hobbytech plz dont mind sister you are in learning phase keep trying

    • @jstro-hobbytech
      @jstro-hobbytech หลายเดือนก่อน

      @@naeemhaq3504 I'm a software engineer ya dope haha

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

      @@jstro-hobbytech but your presentation is good. i like software engineers i am electronics engineer

    • @jstro-hobbytech
      @jstro-hobbytech หลายเดือนก่อน

      @@naeemhaq3504 cool. That's what I should've studied. I'm thinking about going back to school

  • @jstro-hobbytech
    @jstro-hobbytech หลายเดือนก่อน

    Youre a great teacher but that code was overly verbose. I kid, arduinos are for fun and no one needs to be an engineer 😅

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

      Yes it was verbose, but excellent for old people like me that are just starting out. It really helps to see the thought process in writing code.