How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples

preview_player
Показать описание
Embark on a journey from a Arduino coding novice to a prop animation wizard with our comprehensive guide on wiring and controlling a 12V motor with Arduino! You'll be able to program just about any motor, including using Arduino to control a 12V wiper motor, one of the most popular motor choices for DIY motorized props.

This easy Arduino motor control tutorial is specially crafted for beginners who have never written a line of code but are eager to dive into the world of DIY motorized props and robots to program realistic motor movements. Whether you're planning a theatrical setup, a unique art installation, or your next Halloween prop character, this Arduino motor control tutorial is your perfect starting point.

🛠️ Step by Step Arduino Motor Control Guide:
— A beginner-friendly introduction to Arduino and its potential in motor control.
— A clear walkthrough of wiring a 12V motor to an Arduino using a motor driver module along with power requirements.
— Easy-to-understand code examples that you can use and modify for programming your own custom prop movements.

🎬 Video Chapters: How to Control a 12V Motor with Arduino
0:00 - Intro
1:01 - Why You Can't Directly Connect Motors to Arduino Microcontrollers
1:48 - Intro to Motor Driver Modules
3:40 - How to Choose a Motor Driver Module
4:30 - XY-160D Motor Driver Module Pinout
6:38 - Intro to the Arduino Uno Microcontroller
8:04 - How to Wire a Motor Driver Module to an Arduino Uno
10:25 - How to Wire a 12V Motor to a Motor Driver Module
11:40 - How to Wire a Power Supply to a Motor Driver Module
12:14 - Intro to the Arduino IDE
13:22 - Defining Arduino Pins
15:12 - Setting Pin Modes
17:39 - Code Example: Spin the Motor
20:02 - How PWM Determines Motor Speed
21:27 - Code Example: Change the Direction of Rotation
22:20 - Code Example: Set Different Speeds
23:27 - Code Example: Animate the Motor Directions
28:03 - Code Example: Animate the Motor Speed
37:07 - Code Example: Randomize the Motor Speed
39:52 - Code Example: Randomize Motor Speed & Direction
42:04 - Code Example: Randomize Motor Speed, Direction & Timing
43:15 - Wrap up
43:31 - Read the Full Tutorial with Code Examples
43:51 - Join the Community

Build Along:

💬 Have any questions or want to share your own experiences with coding Arduino motor movements? 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 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 #animatronics #halloweenanimatronics #dcmotor #arduinocode #livecoding

#arduino #arduinotutorial #motors #12Vmotors #halloweenanimatronics #halloweenprops
Рекомендации по теме
Комментарии
Автор

I have been a professional software engineer for 30+ years and I have done lots of Arduino programming as well. I watched your video because I am very interested in motor control. The way that you teach is just universally enjoyable and very well structured. Thanks Rachel!

mcintoshdev
Автор

I am a retired Industrial Engineer. I have programmed PLC Controls for decades. I have good learning/Comprehension skills. I've been trying to learn C++ basics and concepts and keep running into "how to" videos from people who have no ability to Teach. Rachel is the first of MANY to break things down and cover EVERYTHING. You write on the screen and explain what "it does" and "why we do this" others, I keep finding myself going out on the Web to find definitions and explanations for terminology and concepts they ignore....so frustrating. Thank you Rachel.

robyounce
Автор

So much fun, I'm a coder and to listen how you explain complex stuff like variable types, program and pulse width modulation that clearly and quickly explains it is refreshing! Keep up the good work!

guyprovost
Автор

Excellent explanation for dummies. You explain like a teacher, very understandable, good job.
I am an electronics engineer, I was a teacher a few years before I was retired, I like your style, keep it up.

ViliJanReber
Автор

As a retired technology teacher, I am in awe of your ability to make progressive changes in your presentation, while making everything completely understandable. You have a special gift.

DavidGierke-nldl
Автор

I was a controls engineer for 45+ years and also taught industrial controls and PLC's at the local community college. You have a very nice teaching style, good job. I just found your channel so what I'm about to say you might have already addressed in another video, but when using Arduino, I tell people to never use the delay() function because the delay() function literally stops the program from executing code. So...if you set a delay(3000) 3-seconds and there is code below the delay(3000) that needs to be serviced during that 3-sec. delay, it will not get serviced. I recommend using the millis() or micros() function and setting a duty cycle with a bit of math for current time and previous time. That way the program keeps "scanning' the loop() function even during the delay.

jtodora
Автор

You explain everything in such a fantastic way. I have been struggling so much with coding because everyone only talks about doing it but you explain it with examples while doing it. Thank you!!!

VintageVash
Автор

Wow, been trying to learn Arduino for many years by reading books and watching tutorials. She does such a fantastic job of using analogies and simple terms while starting from the simple and gradually move to the more complex. I finally get the big picture after just watching this ONE video! What a fantastic teacher….thanks for the video!

MrFalcon
Автор

Wow, I'm a teacher of mechatronics from Flanders, Belgium and wander around the internet for interesthing things I can use with my students and I must say your video is one of the best I've found. A good explanation from zero and building up to your goal. I love it. Thanks for your fantastic explanation and tumbs up.

johangeuens
Автор

Best Arduino demo I've seen so far. Thanks for the information, great teaching technique.

docg
Автор

Wow! I am blown away by your teaching style. You are very easy to follow and I love that quirky sense of humor. I hope you keep teaching.

Mouse_
Автор

First, great video and explanation!
Let me give a few remarks on coding:
1. as another commentator already stated, using #define constants instead of variables for "never changing" or "magic number" values, like pin associations, or the motor's low speed (magic number 70), is better.
2. inherited from C++ (Arduino language is basically a superset of C++), you can use the shortcut var += increment instead of var = var + increment. Works with all arithmetic operators (-=, *=, /=, ...).
3. try to avoid delay(). The processor is literally delaying then, means it does nothing else. You'll get in trouble if you want to do something concurrently then.
4. I'd have the movement of the motor put into a function, like void turn( int direction, int speed ), so you reduce three lines of code into one. Same with stop().

Re my point 3: I've almost nobody seen to address this, albeit this is basic microprocessor programming knowledge I learned almost 40 years ago 😊(Yes I'm an Old White Man, and credits to Professor Reichert of Engineering school Aalen who was a great teacher). I wrote a tiny class that works as a timer and executes code after a specified delay or in specified intervals, or tells you if a delay is over instead of halting the program. Also you can break the granularity down from milliseconds to microseconds, because you can use the micros() function instead of the millis(). The caveat is that this method adds some imponderability to the programs, so you can't predict when exactly which function is executed, because that depends on if some function is busy longer than the time checking interval is.

But great explanation of the Arduino's power capabilities! Overloading ports is one reason why newbies fry their Arduinos and then end up frustrated.

thecalif
Автор

I randomly came across this video by following the "YouTube rabbit hole." I have absolutely zero experience with the Arduino- I've never even seen one in person. I only know of their existence because some people make projects with them in amateur radio (my main hobby). Plus, I'm in my early 50s, so I don't soak up information as well as younger people. However, there wasn't a single thing you presented in this video that I didn't fully understand. Your teaching style is outstanding and you made all the gears click in my brain- and some of those gears are pretty rusty! That's a subscribe for me!

TheREALJosephTurner
Автор

I like the way you speak in a language most of us can understand. Too many people use the very technical language just assuming we all speak electronics and computer code. Nice job.

Nine_
Автор

All I can say is that I wish I had you teaching my first collage course Very interesting and easy to follow. Many or the tutorials on YouTube leave so much out of the expiation You are teaching properly.

RadarRon
Автор

Thank You so much Ms. Rachel!! It was worth spending 45min here.

amey
Автор

Finally, Someone who talks 'How to do' rather than 'Just a do this' You have opened a few doors previously locked to me.

Gixie-R
Автор

You are a great teacher. You really go through everything and don't assume anyone comes in with prior knowledge. If they do they get a refresher.

Isaac-ehuu
Автор

Have been using Arduinos for over a decade now and it's great to see someone who is equally excited about them.

fglatzel
Автор

Many videos only talk about learning but you actually deliver top-level instruction... best I've seen. Thank you!!!

ClayLoyd