Trigger DC Motor with PIR Sensor & Arduino - Complete Guide

  Рет қаралды 9,991

Rachel De Barros

Rachel De Barros

Күн бұрын

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

Пікірлер: 57
@ZenHulk
@ZenHulk 2 ай бұрын
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 2 ай бұрын
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 2 ай бұрын
Thanks for this really well detailed video and for links to each component!
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
No problem! Hopefully it takes some of the guess work out 👍
@meiowalot7570
@meiowalot7570 2 ай бұрын
It doesn't get any better than a new video from you. Thank-you!
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
My pleasure! 👍😄
@xyzheng9672
@xyzheng9672 2 ай бұрын
Really impressed by this informative and practical tutorial video!😃Looking foward to having more potential working possibility with u
@jackrichards1863
@jackrichards1863 2 ай бұрын
Thank you Rachel.
@AEMIROBAYEH
@AEMIROBAYEH Ай бұрын
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 2 ай бұрын
I like this video a lot. 🥳 Smart girls rock. Thank you.
@kyawaung2254
@kyawaung2254 2 ай бұрын
PLEASE KEEP DOING I LIKE WIPER MOTOR SUCH KING OF TUTORIAL
@Jondon-hm7nh
@Jondon-hm7nh 2 ай бұрын
good stuff. Perfect guidance
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
Glad you think so!
@wishicouldarduino8880
@wishicouldarduino8880 2 ай бұрын
I haven't used a pir yet cool video😁
@TT3TT3
@TT3TT3 2 ай бұрын
Thanks!🎉
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
🥳
@dailydoseofnews4828
@dailydoseofnews4828 2 ай бұрын
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 2 ай бұрын
That's a great idea! There are lots of good things to harvest off them.
@jstro-hobbytech
@jstro-hobbytech 2 ай бұрын
​@@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.
@scubaken89
@scubaken89 2 ай бұрын
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.
@HFSPOOKYJ
@HFSPOOKYJ 2 ай бұрын
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 2 ай бұрын
That's a great idea! I've only used the park feature with a switch so far and not with the Arduino.
@HectorRoldan
@HectorRoldan 2 ай бұрын
If Bill and Ted's kids had coding/engineering kids, you would be that awesome thing ❤
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
🤣👍
@damianbutterworth2434
@damianbutterworth2434 2 ай бұрын
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 2 ай бұрын
How has the PIR sensor worked since you put on the resistor? I love your greenhouse cover idea too - great project!
@damianbutterworth2434
@damianbutterworth2434 2 ай бұрын
@@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 2 ай бұрын
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 2 ай бұрын
I have a question for you about an electrical board and also Mopars. Where is a good place to message you ?
@BobMoraneRetro
@BobMoraneRetro 2 ай бұрын
Hello, is it possible to make a tutorial to make the dc motor run with sensor but without arduino or any other materials ?
@kyawaung2254
@kyawaung2254 2 ай бұрын
CAN BE USE WITH ANY KIND OF DC MOTOR?
@TheOldKid
@TheOldKid Ай бұрын
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
@user-hr5dc4ly3q
@user-hr5dc4ly3q 2 ай бұрын
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
@ottopetren8372
@ottopetren8372 2 ай бұрын
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
@darrell271
@darrell271 24 күн бұрын
Why can't I connect the sensor to the Arduino 5v and the motor to the aux+ power connection rather than use the breadboard?
@AnitaLea9277
@AnitaLea9277 2 ай бұрын
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 2 ай бұрын
I can definitely do one on controlling an LED strip with Arduino so you can program some cool lighting animations!
@AnitaLea9277
@AnitaLea9277 2 ай бұрын
@@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 2 ай бұрын
Negelet any negative comment plese keep doing
@robertmatel8136
@robertmatel8136 2 ай бұрын
Hi, are you aware of the "auto format" tool in the IDE?
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
Thanks for letting me know! 👍 I also need to update the IDE to the latest version 🤦‍♀️😆
@g3-is-me
@g3-is-me 2 ай бұрын
@@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 2 ай бұрын
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 2 ай бұрын
My ghost friend (Tesla) just told me about Bluetooth power 😂 - the downside is it constantly makes that motor whining noise 🤣
@RachelDeBarrosLive
@RachelDeBarrosLive 2 ай бұрын
🤣😁
@jeffryweiss4736
@jeffryweiss4736 23 күн бұрын
😩 *Promosm*
@Firemandave911
@Firemandave911 2 ай бұрын
Who else is here just because Rachel is so damn easy on the eyes!!!!!!!??????
@bobmirror7164
@bobmirror7164 2 ай бұрын
She looks like she could be my old girl friends kid.
@TheOldKid
@TheOldKid Ай бұрын
End up watching multiple times because she tends to pull attention off components. Oh well. It helps view counts.
@naeemhaq3504
@naeemhaq3504 2 ай бұрын
too many mistakes in the video
@jstro-hobbytech
@jstro-hobbytech 2 ай бұрын
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 2 ай бұрын
@@jstro-hobbytech plz dont mind sister you are in learning phase keep trying
@jstro-hobbytech
@jstro-hobbytech 2 ай бұрын
@@naeemhaq3504 I'm a software engineer ya dope haha
@naeemhaq3504
@naeemhaq3504 2 ай бұрын
@@jstro-hobbytech but your presentation is good. i like software engineers i am electronics engineer
@jstro-hobbytech
@jstro-hobbytech 2 ай бұрын
@@naeemhaq3504 cool. That's what I should've studied. I'm thinking about going back to school
@jstro-hobbytech
@jstro-hobbytech 2 ай бұрын
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 2 ай бұрын
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.
Motion-activated Servo Motors with Arduino and PIR Sensor
25:20
Rachel De Barros
Рет қаралды 20 М.
🍟Best French Fries Homemade #cooking #shorts
00:42
BANKII
Рет қаралды 58 МЛН
Чай будешь? #чайбудешь
00:14
ПАРОДИИ НА ИЗВЕСТНЫЕ ТРЕКИ
Рет қаралды 2,8 МЛН
When Jax'S Love For Pomni Is Prevented By Pomni'S Door 😂️
00:26
Motion-activated Sound Effects with Arduino, PIR Sensor & MP3 Player
25:26
How to Wire Multiple LEDs: Series vs. Parallel LED Circuits
21:24
Rachel De Barros
Рет қаралды 39 М.
Everything You Ever Wanted to Know about Wiper Motors
26:09
Daniel Simu
Рет қаралды 30 М.
Cheap and easy motor for props
6:02
Brian Benson
Рет қаралды 12 М.
High precision speed reducer using rope
20:19
Aaed Musa
Рет қаралды 1 МЛН
How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples
44:13
DIY Hidden Pressure Plate Switches: Trigger Props & Lights Like a Pro!
20:34
PIR Sensors And How To Use Them
21:01
Simple Electronics
Рет қаралды 25 М.
Driving DC Motors with Microcontrollers
1:04:32
DroneBot Workshop
Рет қаралды 593 М.
Mem VPN - в Apple Store
0:30
AndroHack
Рет қаралды 84 М.
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,6 МЛН
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1 МЛН
Где раздвижные смартфоны ?
0:49
Не шарю!
Рет қаралды 819 М.
Samsung S24 Ultra professional shooting kit #shorts
0:12
Photographer Army
Рет қаралды 12 МЛН