Arduino Tutorial 35: Understanding How to Use a Stepper Motor

  Рет қаралды 303,235

Paul McWhorter

Paul McWhorter

Күн бұрын

Пікірлер: 1 000
@Seftdelmer
@Seftdelmer 3 жыл бұрын
For those that are doing this with the kit, please note that the supplied 9V battery may not be sufficient to drive the stepper motor (via the driver). When I first tried with the supplied battery, the stepper motor made a noise but didn't turn. I then swapped the supplied battery with a new one, and the stepper motor turned. Thanks to Paul for these excellent videos.
@sebastiannunez4878
@sebastiannunez4878 2 жыл бұрын
was the new battery any different?
@AlexDavis-ch1ro
@AlexDavis-ch1ro Жыл бұрын
Yep, me too. Mine came with a Piscell 9V: obviously not up to the task. Energiser did the trick!
@Lucky-ek8tv
@Lucky-ek8tv Жыл бұрын
same
@Thejbelow
@Thejbelow Жыл бұрын
Even with a brand new battery it's weak. Can't beat a power supply
@roncarrier4205
@roncarrier4205 2 ай бұрын
Mine worked for a bit and I checked the battery with my most excellent multimeter. The voltage turned out to be a little bit over 6 V! So I’m surprised it worked at all.
@thomasmiller3398
@thomasmiller3398 2 жыл бұрын
Currently in my second year of aerospace engineering at university and have never touched an Arduino or C++ before and was given a project requiring the use of multiple stepper motors, sensors, buttons and LEDS and I cannot stress enough how much these videos have helped me. Thank you so much for making such high quality free material! I know there will be others like me in similar situations and your videos will have saved them as much as me.
@zvone908
@zvone908 Жыл бұрын
Hi, I'm thinking about studying aerospace engineering after high school. Can you recommend any books worth reading, or give any advice other than that? Thanks in advance :)
@peterknoll8906
@peterknoll8906 8 ай бұрын
I know it's an old video. I don't know if you read the comments here. I did the homework as you said, without having seen your solution to that. I did a attach.Interrupt and with it i called a function "reverse", ive made. In this function, i reversed direction. My quick and dirty way of spinning infinitely in the main loop, was to start of with "while (true)" It's at least a very short code, by having the same outcome. I've did a INPUT_PULLUP command on the pinmode. That works great. Thank you Sir, for your educational videos. Ive learnt a lot from you!
@mxcollin95
@mxcollin95 5 жыл бұрын
This channel is a gold mine! I’ll definitely be working through your arduino and RasPi series!!! Wish I would’ve had a teacher like you when I was in high school. 👍
@sameeras6566
@sameeras6566 4 жыл бұрын
SOOO TRUU BRO!!
@saeidkasraeian190
@saeidkasraeian190 3 жыл бұрын
Exactly 👌
@JonPeroutka
@JonPeroutka 2 жыл бұрын
You, sir, are the Bob Ross of engineering. Thank you for your great tutorials.
@mau19885
@mau19885 5 ай бұрын
so on point! stealing this since I tell so many people about him :)
@MatlasX
@MatlasX 4 жыл бұрын
This is definitely one of the lessons where you could have probably spent a bit more time explaining how the stepper motor works in this particular case. Pins 8, 9, 10 and 11 were used, but really not sure what they do.
@misterdecaro
@misterdecaro 2 жыл бұрын
I agree, I'd like to know more details about why those specific pins and why the order of pins 9 and 10 are swapped in the Stepper setup call.
@jafaralturfy5053
@jafaralturfy5053 2 жыл бұрын
The stepper motor has 4 coils each coil is connected to 5v through these pins.
@syedsajjadali4220
@syedsajjadali4220 2 жыл бұрын
@@jafaralturfy5053 thanks mate
@chadmorreale
@chadmorreale 2 жыл бұрын
@@misterdecaro I believe this is just due to the ribbon cable and wanting to put them in order physically on the connectors.
@davidransier
@davidransier Жыл бұрын
OK, not so sure this comment will be helpful, but here goes. I read the Documents included with the Elegoo kit and it says the four pins are a four-bit code to the stepper. That says to me that they should be in order. I confirmed this by reading the Stepper.h file (found in Github). However, when I put the in numerical order the motor only spins one direction, regardless of the Step value. When I SWAP PINS 9 7 10, the direction swaps correctly when I push the button. Bottom line, we need more info from Paul M!
@ericroque5813
@ericroque5813 7 ай бұрын
For those who had trouble doing this, take note of the right sequence of pin declaration which is 8, 10, 9, 11 as this is the right sequence for half step. I put the pin number in ascending order thinking it was just as simple as naming the pin number as I plug it in the arduino board. But no, the right order mattered. Took me a while to figure this out.
@jaymzhowlett3984
@jaymzhowlett3984 5 ай бұрын
Thank you friend 🥳
@bjornakeSwe
@bjornakeSwe 3 жыл бұрын
I'm a retired swede of 71. I've been an engineer for 50 years. My first experiece with computers was my Commodore 128 and Basic. I do remember the com speed of 9600 and sometimes even 2400. After that it has mostly been hardware. I discovered the Arduino and got interested. I stumbled on your videos and was hooked. After watching a number of them I realised I had to get the Super Duper Kit. So it is ordered but not yet received. So far i've watched your videos to the end, but programming them in my head, so when I get my kit I think I must start from scratch and do it irl. I've also noted that you have videos about RasPi and Python, so I don't need to be bored for a long time. I have a number of ideas that can be solved with the Arduino and some coding instead of a bunch of CMOS/TTL IC's. Like so many others in these comments i wish I had a teacher like you at school.
@gusmon83
@gusmon83 2 жыл бұрын
That last bit there put into the void loop threw my brain a curveball. Finally figured out it was "buttonValOld=buttonValNew;" as the last line of the void loop. Paul, I've been bingeing these lessons and crushed 35 in three days. You've done an incredible job, here. I knew nothing but was able to follow until you said "pause" AND THEN able to program this in my own way, unfortunately vastly different and of course with different results than you were able to provide here. Things happened, but it was still on delay and made a full rotation and then reversed. Invaluable lessons. THANK YOU!
@bm5211
@bm5211 4 жыл бұрын
Thank you so much for these wonderful tutorials! As an ecology student, I have never in my life touched anything to do with electronics or mechanics before watching your Arduino series. But now, 35 episodes later, I am amazed to say I can still follow along with everything. :) Every time you introduce a new part I get so many ideas for hobby projects! I genuinely never thought I would be able to understand anything to do with wires and circuits, but your explanations have made the impossible possible. Thanks again, you're the best!
@misterdecaro
@misterdecaro 2 жыл бұрын
Before watching this, I just want to say that I wasn't sure if I was going to 'bother' going back to watch you first series, your 'lessons' on Adruino. But now I can say that I will definitely go and watch them also! I was looking for something specific and I found it in one of the lessons and, I have watched a couple of others too! At any rate, to my fellow followers/subscribers/learners, the first set of lessons Paul offered is definitely worth your time and effort. Thank you Mr. McWhorter!
@TheSelfUnemployed
@TheSelfUnemployed 2 жыл бұрын
Unable to complete the homework on my own but grateful for the lesson! Thank you Paul!
@rogthedodge99
@rogthedodge99 4 жыл бұрын
I did it using lesson 28 as a base. My motor only reversed when it had reached 1 revolution because I'd left the number of steps at 2048. My stepper direction was based on the button val. I now realise you can step 1 at a time, and in the same direction until told otherwise. Thanks Paul. It really is worth trying things yourself first, even if it's not quite right.
@christianorlandoibarragarc3904
@christianorlandoibarragarc3904 2 ай бұрын
Took me 2 minutes to do the assignment, I notice that being an experienced developer helps a lot even though I am totally new in the electronics part.
@sampleexamplemusic
@sampleexamplemusic 3 жыл бұрын
GIDDY UP. ok this dude rules. going back to the beginning and watching all of these because he's an awesome teacher!
@ancienttechnologiespinball1690
@ancienttechnologiespinball1690 9 ай бұрын
Hello Paul. I'm an Electric Mechanical pinball technician from Toronto, Canada. I built a pinball machine using parts from the '70s, but for mass production i need to use Solid State Electrictronics. That's why I'm here. Yes, i watch every video to the end, more than once. I take screen shots of coding and try not to look at the pictures later, but normally need to because I'm still learning the language. Same with the math. I failed math in high school and happy to learn it now. The wiring comes naturally to me. i've always been good with electricity and mechanical thing. I find no part of videos boring . Thank you for making them. My board broke down this morning, so while I'm waiting for a new one, I'm gonna start watching again from episode 1 and see if i can call the shots before you make them.
@donaldtroll7537
@donaldtroll7537 3 жыл бұрын
The battery from the kit died within a few minutes and made me think I unplugged something. Plugged in a new battery and everything worked. Another great video, Paul.
@kenmeyer100
@kenmeyer100 3 жыл бұрын
same here. Luckily I found the culprit with a voltmeter
@pudgepatenaude3481
@pudgepatenaude3481 3 жыл бұрын
So glad I read the comments. My motor would only spin one direction until I switched pins 2 and 3 on the motor controller.
@sandeepjadhav3565
@sandeepjadhav3565 4 жыл бұрын
I am following you since lesson 1, and i would like to say I was able to do homework on my own. thanks to you.
@keyboardlearning7552
@keyboardlearning7552 2 жыл бұрын
I'm a retired electrical engineer, following your videos for the fun of making a device follow the projects. I made this work, in a similar manner to how you taught us to toggle with the buttons. That was more elegant than my last attempt. (Sorry I haven't waited to get to the end of the video to get the magic word.)
@dash8944
@dash8944 4 жыл бұрын
If any of you are having issues getting the stepper motor to rotate, try swapping batteries - the one that came with the kit didn't work for me. My motor was vibrating but not rotating (the LED lights were not coming on either). Hope you find this friendly advice helpful. (Thanks Paul for your amazing videos btw)
@sedcdf
@sedcdf 4 жыл бұрын
Thanks, i need to switch batteries then
@sedcdf
@sedcdf 4 жыл бұрын
it worked thanks.
@frankbonsignore.RochesterNY
@frankbonsignore.RochesterNY 10 ай бұрын
Thank you for suggesting this.
@damoffat
@damoffat 3 жыл бұрын
I managed it, looked back on the old button toggle code to help remember what I did back then. My only problem was leaving the number of steps at 2048, and the delay of 500ms - it almost never read the button. Then I cut it down to 10 steps and shorter delay and it worked better. My code inside the if statement was direction=-direction. Thanks for another great lesson. It's been a while, but I've been having fun with the other stuff I can do!
@stefstaf
@stefstaf 4 жыл бұрын
These are invaluable lessons and thank you Mr. McWhorter for taking the time (and the pain) to make them for our benefit. The synchronus presentation of the code, the printout and the experiment makes these lessons the best you can find in the subject. I had a little difficulty understanding the stepper commands that came out of nowhere but then I realized that these commands are hidden in the accompanying libraries. If you intend to devote one of your wonderful lessons in explaining Arduino librabries and how they "generate" the new commands we would be for ever grateful sir.
@emiliomartineziii2980
@emiliomartineziii2980 Жыл бұрын
For anyone who is having trouble try using a 12V supply instead of the 9V battery. When I did it with just the battery from the kit, it didn't work, but when I took two double A batteries, put them in series with the 9v battery from the kit, and then used the total 12V supply, it worked!
@thebrewsterblock
@thebrewsterblock 8 ай бұрын
Hey Emelio. Having the same problem even with a new 9v. Where is the 12 v input? Or did you feed 12 thru the 9v?
@tretty07
@tretty07 4 жыл бұрын
Racked my brains for a couple of hours trying this one, I got it to change direction but only after each full turn, excellent lesson, learning something new each time.
@3dpprofessor
@3dpprofessor 3 жыл бұрын
Sorry, super late reply, but decrease the amount of steps between each check. Heck, you can have it check after every 1 step.
@wayneandersen7596
@wayneandersen7596 4 жыл бұрын
I did it. I only had a couple of differences. I did 10 steps per loop and I changed direction on button release instead of button push. Thanks for doing this series!
@CarolinaDGF
@CarolinaDGF 3 жыл бұрын
Thanks to all the instruction leading up to this video, I was able to do it on my own. You are a great teacher, Paul. The only thing I struggled with was getting the first part to work at all. As soon as I would plug in the stepper controller, the light would go out on my power supply. Turns out the battery in the kit did not have enough power. Glad I ordered a 9V Arduino wall wart when I ordered my kit. Plugged it in and all was well. (All was well after spending several minutes checking my wiring before pulling out my volt meter to see what the battery was not putting out enough power....)
@arjodas
@arjodas 2 жыл бұрын
thanks man I think I have the same issue lol
@pointer333
@pointer333 2 жыл бұрын
I'm glad I found this comment so I didn't have to pull out my meter lol! Had a rechargeable lithium 9V laying around from my pro sound work and everything is working now! Man, the brand new provided battery lasted about 30 seconds hahah!
@stevenog
@stevenog 2 жыл бұрын
Same problem here, no name batts are notorious for being junk. The updated link leads to a larger kit (The Most Complete Starter Kit) which includes many more parts (twice the price) including the wall wart.
@RobVollmar
@RobVollmar Жыл бұрын
I was able to do the "homework" on my own. This time through the series, I've been meticulous about saving old programs. Every time we have an assignment that references something we've done before (like the toggle button in this assignment), I open the older program and try and figure out how to adapt it for the new use case. Occasionally, I'll actually have to go back to the lesson where it was discussed (for example if I don't remember how to set up the circuit) but thus far, the code is usually enough to jog my memory. Several programmers I have talked to have told me that knowing how to adapt existing code is almost as valuable as writing that code the first time and I took it to heart.
@Panvil
@Panvil 4 жыл бұрын
I did it on my own, but made it way too complex. Thanks for the great lesson Paul. Much love.
@chrisortilla6111
@chrisortilla6111 Жыл бұрын
I have just been copying you as you go because, I've picked up the lessons again after some time away. Trying to let my brain get refreshed! Thanks for another great tutorial.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Excellent!
@27prajjwalprasad43
@27prajjwalprasad43 4 жыл бұрын
I did it on my own but in a muuuuuch more complex way. I was shocked to see that you made it work in just 5-6 lines of code!!!
@sreerajguptays3531
@sreerajguptays3531 3 жыл бұрын
Hi could you please send me your work to wrekjohn@gmail.com
@ghaniyyahmbello4393
@ghaniyyahmbello4393 Жыл бұрын
Mr Paul, your tutorials are really interesting and educative, breaking down every little detail. Thumbs up for the good job.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Glad you like them!
@karelenmarritkruyswijk393
@karelenmarritkruyswijk393 5 жыл бұрын
Who wouldn't get exited for electonics looking at these video's... Thank you. Thinking about using the stepper motor for domotica opening and closing curtains depending on time of the day if possible.
@TheRaptor1967
@TheRaptor1967 4 жыл бұрын
could use in conjunction with the light sensor. Auto Open curtains in the morning, close in the evening. Good security gadget for when your away? Would need to pick values carefully, would give the game away if they kept closing when a large cloud obstructed the light. :)
@filipegameiro4344
@filipegameiro4344 Жыл бұрын
I was able to do it. And I really want to thank you for your work, it's the first time I can do something only with lessons given on youtube.
@satisfactoyz
@satisfactoyz 3 жыл бұрын
I wasn't able to figure it out, sad to say. I made it switch, but only after each command cycle finished. I didn't realize you could get continuous movement by multiplying by 1 and -1. Anyway .... it was an eye opener. Thanks again, Paul.
@destinyokwong2099
@destinyokwong2099 5 күн бұрын
I did it myself sir I used a very similar method sir Thanks to your lessons Steps = -steps But I prefer the way you did it.
@miketurley9277
@miketurley9277 3 жыл бұрын
Hello Paul, I appreciate your lessons. You have inspired me to learn this stuff in sequence not just dig around for what I am looking for. The kit definitely makes this easier than digging through my junk. I hate digging! I wanted to share a bit of my own knowledge with you. Although there may have been another comment or possibly just messing with some of the electronics newbies but either way ROHS isn't the MFR (I beleive this device is from Kiatronics). of the motor it is a qualification for hazardous materials used in the manufacturing process of stuff, usually electronic components. ROHS compliance was a standard that started in the late 90s-early 2000s. I hated the PB free solder, it just doesn't flow like the old stuff...
@vandanasrivastava2028
@vandanasrivastava2028 4 жыл бұрын
I am from class 6 and during this outbreak I have learned how to code and use an arduino board. Thankyou sir for teaching like this.
@christopherchance4860
@christopherchance4860 4 жыл бұрын
Where were you when I was in High School? Thank you for your enduring hard work, I have learned so much from you and your tutorials
@chrisgosling5408
@chrisgosling5408 2 жыл бұрын
More great Advice from Paul is to always set the serial up for debugging, this helpd me to get the case statements in the right loop.
@lordstelanthin
@lordstelanthin 4 жыл бұрын
I did this one on my own, but wow did I overcomplicate it.
@giorgimikeladze4739
@giorgimikeladze4739 3 жыл бұрын
i did this and i undercomplicatet it
@giorgimikeladze4739
@giorgimikeladze4739 3 жыл бұрын
you dont even need buttonval old
@MarcReeveNewson
@MarcReeveNewson 3 жыл бұрын
Another easy one. Took the downtime to explore whether the Arduino can be doing anything else while moving the motor. So I'm seeing the value of multi-tasking.
@jefejc
@jefejc 3 жыл бұрын
These lessons are making me think hard but that's good for my old age
@chrisgosling5408
@chrisgosling5408 2 жыл бұрын
One those projects where there are three things to get working and you can always get any two at one time. I was running first time with two but it took another three hours to get all three.. I was delighted to get the result. Writing code is always about thinking differently and learning at the same time. We are down to 4K likes so I guess this is the hard core that will persist. Good to know that there are that many people out there who will go the extra mile rather than skip reading and looking for quick fixes. With development I have found that in designing the current project you always need to think about how this will lead into its successor. Taking short cuts that will eventually become long cuts as you box yourself into a corner!
@gitarlos
@gitarlos 5 жыл бұрын
the elgo driver does not work some times unless you switch IN1 with IN4 .
@shatann
@shatann 4 жыл бұрын
That's right! How'd you figure that out?
@thomaseardley2900
@thomaseardley2900 4 жыл бұрын
thank you bro you saved me hours of trouble shooting
@godwincornelius6285
@godwincornelius6285 4 жыл бұрын
Wow what a life saver..... I wish Paul would have mentioned that... Thanks a lot by the way.... Because the stepper motor was misbehaving
@leonhardeuler8457
@leonhardeuler8457 4 жыл бұрын
Well it didn't work too
@leonhardeuler8457
@leonhardeuler8457 4 жыл бұрын
Don't do this it may damage ur driver Mine didn't work too and I used ur method and it worked but when I changed the code to stepsperrevolution/2 it didn't work Instead of doing that change ur battery my problem was battery
@adamcurtice3584
@adamcurtice3584 2 жыл бұрын
This is the first assignment that I was unable to complete. I did not occur to be to multiply by -1 to solve this. While I was trying to analyze what was going on by using the Println command nothing would print until a full rotation was completed. Then all I got was 2048. I kept drawing a blank on how to Solve the problem. I guess I should work on these earlier in the day. Thanks for the simple solution. Keep up the good work.
@michaelcostello6991
@michaelcostello6991 4 жыл бұрын
My battery died almost immediately. Lucky you warned us so we didnt panic and measured the voltage to confirm.
@jimmyjimmereeno3341
@jimmyjimmereeno3341 4 жыл бұрын
Same here. The low-cost battery that comes with the kit lasted less than 5 minutes. I was afraid that the motor or driver board had fried.
@christianvanderniet
@christianvanderniet 3 жыл бұрын
@@jimmyjimmereeno3341 yup i had the same exact thing the battery went out so i hooked up a extarnal power suply that can go to the net
@Michael_Harrigan
@Michael_Harrigan 3 жыл бұрын
I wish that all KZbinrs had your ability to understand a student’s perspective and have the ability to thoroughly teach every step in the process.
@MahBor
@MahBor 3 жыл бұрын
When the stepper motor starts moving, some components on my breadboard power supply module start heating up to the point where they burn my fingers if I touch them. Is this normal? I'm really worried and don't wanna burn my module so I've stopped using the stepper motor.
@khaledalaryani776
@khaledalaryani776 3 жыл бұрын
You are probably running more current in the components that you should be doing and that is why it’s heating up
@souljr.
@souljr. 8 ай бұрын
Took me a while of troubleshooting/looking back at notes (like 30-45mins) but I finally got the program working to a fairly smooth point. I'm sure there's a much better way than what I've done, but I'm just happy to have gotten the homework done without listening ahead! Figuring out where exactly to put the delay( ) command in my program was the tricky part. I decided to use do...while loops to make the motor keep going until the button is pressed then change direction. Probably one of the main reasons I was having issues with the proper delay time location within the blocks.
@pranavshool
@pranavshool 3 жыл бұрын
Yeah, I did it by using different logic!
@gghutton
@gghutton 4 жыл бұрын
I spent 3 hours trying to figure this out on Saturday. I knew I wanted to change directions with multiplication with a '-1'. I also went back to #34 to see how the button was set up. I also added a RED and YELLOW LED lights to show which direction the motor was spinning. So I did come back here to follow step by step.
@SarkarMotion
@SarkarMotion 5 жыл бұрын
"Stepping" up the difficulty I see! This lesson was a "stepping" stone, one might say. Oops! Sorry, looks like I "overstepped" my limits here. 😶😍
@VivekYadav-ds8oz
@VivekYadav-ds8oz 4 жыл бұрын
You, sir, have earned my respect.
@ramraja7796
@ramraja7796 4 жыл бұрын
MotiOnTech , You have taken a step in a right direction but now you must step back.
@minab45
@minab45 4 жыл бұрын
You should be removed from this channel, that'll servo right.
@jimivie
@jimivie 4 жыл бұрын
you need to step off with all these puns!
@codingvio7383
@codingvio7383 4 жыл бұрын
No you didn't, you are just getting started
@adriennehuntress2987
@adriennehuntress2987 3 жыл бұрын
I had the same experience as several on this video- the 9V battery that came with my kit died very quickly. BUT I didn't realize that since I heard/felt the stepper motor sort of kind of doing something, and went too quickly to the conclusion that my stepper motor was 'bad'. Glad I saw others posting that changing out the 9V worked. Did the trick for me!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Nice troubleshooting. Always suspect bad connections and batteries before anything else. Seems the components themselves are rarely the culprit. Thanks for the comment.
@KisorcererAMP
@KisorcererAMP 4 жыл бұрын
For the life of me, I could not understand this one. I've rewatched the toggle video multiple times and it seems that when a project involves toggles I struggle.
@garysenier2440
@garysenier2440 4 жыл бұрын
me too
@favesongslist
@favesongslist 4 жыл бұрын
You could try using two buttons for now to prove the stepper motor sketch, one for clockwise and one for anticlockwise, and then go back to the earlier tutorial for making a toggle work.
@favesongslist
@favesongslist 4 жыл бұрын
​@@garysenier2440 the trick to understanding the toggle function is that you are detecting the button change from 0 (not pressed) to 1 (pressed) over time. So step1: read the button, if 0 then lastPress=FALSE step2: read the button again and if lastpress==FALSE and the Button is 1 change lastPress=TRUE; to Make sure the toggle only happens once per press. change the Toggle state, if it was 0 make it 1, or if it was 1 make it 0. Instead of using an int it may help to use a boolean (can be either 0 or 1) bool toggleState=0; int lastPress; int buttonVal; buttonVal=digitalRead(buttonPin); IF (buttonVal==0){ // Checks if button not pressed lastPress=0; // this makes sure the toggle next press } ELSE { // Do this when button is pressed IF (lastPress==0 ) { // Check for only once per button press lastPress=1; // stops repeating while button still pressed toggleState=!toggleState; digitalWrite(LEDpin, toggleState); } }
@karamyounis15
@karamyounis15 4 жыл бұрын
Hey, idk if you still need help with this but I'll try to give it a shot. The original "if" statement reads "if(oldButtonValue==1&&newButtonValue==0){" ; the "oldButtonValue" is defined by you, in this case it's a 1, the "newButtonValue" is defined by this command "newButtonValue=digitalRead(buttonPin);". Now, the "if" statement is not true (the arduino will not run the commands underneath the "if" statement) until both parameters (oldButtonValue and newButtonValue) are met. Since oldButtonValue is defined by you, it is true from the start, and since newButtonValue is defined by the press of the button, the "if" statement will only work when "0" is read, or when the button is pressed; at this point, everything you put in the "{ }" will run. I hope I made some sense.
@bobpattenden
@bobpattenden Жыл бұрын
This is my favourite lesson so far, so much of what has been taught over the past few lessons, all came together and made perfect sense.
@Ninethepoet
@Ninethepoet 4 жыл бұрын
21:52 this is everyones reaction when their first line of code works! P A S S I O N!!!
@i_thesnoman5198
@i_thesnoman5198 4 жыл бұрын
dang thats some passion!
@gunnarwaldschmidt7640
@gunnarwaldschmidt7640 Жыл бұрын
Pay very close attention, I spend 2 hours figuring out how important the numbering on the stepsPerRevolution definition is, if you use 8,9,10,11 instead of 8,10,9,11 your motor will only run in one direction ;-) Afterwards tried the homework, but failed. Thank you Paul for you time, you are a gem to this world. You opened my mind to so many new options!
@andrewbeshay6052
@andrewbeshay6052 Жыл бұрын
THANK YOU! I've been trying to figure this out for an hour
@ckat609
@ckat609 Жыл бұрын
Thank you, good sir! I guess I must be dyslexic
@ralphmarks2727
@ralphmarks2727 2 жыл бұрын
many times through before I realized my push button only works on one side, and my power/ground rails only work halfway across either side. plus a fist full of coding mistakes, several times through, you held my hand the whole way. I thank you so much.
@geralddrake4617
@geralddrake4617 4 жыл бұрын
Had a little trouble with getting the stepper motor commands correct. Failed the homework assignment but gave it a good try. Steeper motors are so important for good projects. Thanks for sharing your knowledge for FREE on these videos.
@preetamsingh147
@preetamsingh147 4 жыл бұрын
I had attempted to do it by myself, but my solution was partly correct. And yours is perfect, so yes I did copy you, but after putting in my efforts in the solution. THANK YOU!
@rachelglover4733
@rachelglover4733 4 жыл бұрын
For those it may help my motor was wired a little differently and after some trial and error needed IN1 to Pin 11, IN2 to Pin 8, IN3 to pin 10 and IN4 to pin 9. Thanks for the lessons Paul - learning a lot!!
@חייםלב-ז7ו
@חייםלב-ז7ו Жыл бұрын
i did it in a diffrent way, but my method works only with a short click. that was a great lesson, thank you very much!
@connorduffy4138
@connorduffy4138 3 жыл бұрын
I'm working thorugh these tutorials in 2021. An absolutely fantastic resource, thank you! When creating the Stepper I accidentally set the pin sequence as 8,9,10,11 - not 8,10,9,11 as it should have been. This resulted in the motor buzzing but not turning. It took a long time to work out why! If another viewer is haveing similar issues, it's perhaps something to check.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Great job!
@painfullgaming8667
@painfullgaming8667 2 жыл бұрын
im having the same problem as you but your solution does not seem to work for me. When you say set the pin sequence you mean the order in which you plugged the pins in the arduino or you mean the way the pin are listed in the code?
@painfullgaming8667
@painfullgaming8667 2 жыл бұрын
found out what the problem was....the batery was just not having an output of 5v so thats why the controller would not power up :0
@sebastiannunez4878
@sebastiannunez4878 2 жыл бұрын
@@painfullgaming8667 i have the same problem.. for some reason when I run an empty program the output voltage of th battery is 5V. However, when I run the program of the step motor it goes down to ~2V and therefore I don't see any movement; just a buzz.
@Jim-mn7yq
@Jim-mn7yq 4 жыл бұрын
Yes, I was able to get it working. But I almost immediately ran into hardware issues. I got the initial stepper motor to turn, but shortly after that the green led on the power supply started to dim and ultimately all lights on the driver went out. Turns out the battery in the kit was almost doa on delivery. As a result, I discovered what Paul mentioned, ie, these motors gobble up a lot of amps and can drain a battery quickly. Also the power supply doesn't seem to operate well with much below 8.5 to 8 volts. Once I got that figured out, it wasn't too bad. The hack on the pin was pretty obvious, and for those of us who've followed along, the toggle code was almost identical. All in all, a very challenging tutorial. And one I'm sure many of us learned from, including expanding our troubleshooting abilities.
@DirkSimilon1
@DirkSimilon1 3 жыл бұрын
It's amazing for me, totally newbie in the art of electronics, that sofar I can follow and understand everything our beloved teacher says and explains, and more. He even made it possible for me to really be happy about the working of circuits. Through you Magic comes True, Paul. But the Stepper-lesson was a hard one. Nothing worked - I controlled all wires, buttons,....no movement of the motor, no lights on the driver. I measured a correct current on the breadboard and the controller though. I read en reread the code and made changes according to reactions of other students, I replaced the battery and even made a direct connection to the arduino-5Vpin. I even filled my cup of coffee with ice-tea. ..Nothing happened. Almost on the point of loosing all my hope, i wondered what those 2 unused pins on the motordriver did. I found out that they were meant for an on/off switch! ....and unconnected..??? so...I connected them and BOOM BOOM BOOM BOOM BOOM BOOOM boooooooM!!!!!!!!!!!! Never give up, you guys and girls ps shouldn't those pins not be covered by a little cap or something like that - or was i so unlucky to miss that in my Elegoo Super Starter Kit?
@steveholt8991
@steveholt8991 5 ай бұрын
This series is still relevant today. I've learned so much going back to the basics. Thank you very much Paul.
@Mrerrol13
@Mrerrol13 3 жыл бұрын
I finally got it! I used the switch, "the old-fashioned way", with the resistor (I forgot the new system), but at the end it worked. I had problems with the change of direction; first because I had it at full turn and then because I discovered that printing the values on the screen slowed down the program so much that it didn't detect the press on the switch. It was too much work because of my clumsiness, but I finally managed to do it in a similar way as you did, Paul. Thanks so much!!!
@hedgewicksattempts
@hedgewicksattempts 2 жыл бұрын
Spent quite a while on this one. Threw in a potentiometer to set the motor speed 1-10 as well just to do the math. It's kinda working but I can only change the rotational direction when the switch is toggled during the delay time. I accept my failure and shall watch and learn now!
@ethanwright501
@ethanwright501 3 жыл бұрын
I did it but I kept the steps per revolution, and multiplied that by -1. And I messed up the which pin the button needed to be connected to, so I ended up going back to basics and using a resistor. Your way makes a lot more sense.
@karansunar4458
@karansunar4458 4 жыл бұрын
you are the best teacher i ever seen my life...
@AlexDavis-ch1ro
@AlexDavis-ch1ro Жыл бұрын
I paused, and was able to make it work, although the method I used was temperamental and wouldn't always change direction. I tried to change the variable using a (-1) multiplier and used your easy button hack, but I forgot about the (&&) command in the 'if' statement. Thank you for your teachings; every evening I'm able to learn something new, and it gives me something to ponder during the day, and how I can use it in future projects. Much love!
@malcolmsnow4799
@malcolmsnow4799 2 жыл бұрын
Love it - Due to the gear reduction system inside the little stepper motor, the actual steps per rev works out to be 32/9*22/11*26/9*31/10*32 = 2037.8864197530864197530864197530864197530864197531 I'm having fun and watching all of your videos --- Thanks Mal
@erikburman530
@erikburman530 2 жыл бұрын
I'm so glad I stuck with this and figured it out on my own. I went through so many wrong turns but when I finally realized how to make it work the solution was so simple I had to do a facepalm! Very rewarding! And now, on to session 36.
@JohnB-r6c
@JohnB-r6c Жыл бұрын
Was able to almost complete homework. My stepper would not change directions until completion of the revolution cycle. Great Lesson again Sir.
@tonytungate4540
@tonytungate4540 3 жыл бұрын
I did the homework, worked out quite complicated on the first attempt, but then went back and reviewed lesson 27. Much cleaner code on the 2nd go. This one made me think alot!! definatly taught me to think it through before diving in, and work out a flow diagram.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Excellent!
@carlos2004
@carlos2004 5 жыл бұрын
I managed to successfully get the project working (although it did take me a bit of time), and i have to say after using my method, your solution was really neat way of using the negative/positive to control the direction. I used a longer method which i figured out from doing one of my own programs. the goal of that one was dimming an RGB LED individually. Button A would brighten, B would dimm, and C would select which RGB A and B would actually control. Basically, after many failed attempts, i ended making button C a glorified counter (0=R, 1=G, 2=B), then loops back (if 3, then value=0). after that, i simply added "if" statements for each value (if 0, A/B buttons control red, if 1 then green, and if 2 then blue). That allowed me completely separate anything each individual "if" statement is doing, and the button press is only strictly in charge of the selection. So basically i ended up making a "selector" switch which i guess will come useful for later later projects since for a simple toggle, it's a bit too much work.
@paulrockwell9914
@paulrockwell9914 3 жыл бұрын
I too found my 9V battery running out of juice while watching the video. In fact I had just noticed my motor has stopped working, checked the battery with my handy dandy multimeter and switched over to the AC adapter at almost the same time you noticed your battery was exhausted. Nice lesson - and I was able to complete it as “homework” when the video was paused.
@Mr_Jonathan_Greer
@Mr_Jonathan_Greer 3 ай бұрын
I did the HW, but I did mine completely different and in a way more complicated way. I set up 3 while loops based on the value of butNew and butOld. Your way was way simpler!
@BRIANCLEMENT28
@BRIANCLEMENT28 3 жыл бұрын
Got the joystick to control the stepper in the y and the servo in x. then I put a red toggled LED on the end of the servo. should have used the Green LED cuz this was s special occasion. You Rock Mr.M
@tvmovieschannel1297
@tvmovieschannel1297 2 жыл бұрын
I tried doing the homework, and it didn't went that well, cause I messed up on my (if statement) So I Gat to watch u do it sir. But am really glad that am getting better on this. And that's cause of ur help and teaching style. 👍👍👍
@MatsSjoq
@MatsSjoq 2 жыл бұрын
Thanks Paul. I've followed every lesson to the end. Done all home work. I'm writing extensive comments in all my programs so that I can understand what I've been doing. Also used the Reference under Help, which has been very helpful. Unfortunately the battery with the kit was lousy. The stepper motor stopped working after a minute. Luckily you mentioned you hade to switch batteries. Now it works again.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
The battery is useless. Lasts about 10 seconds.
@grelca
@grelca 2 жыл бұрын
since i am following these tutorials using micropython instead of c++, this one was kind of an adventure for me! i almost gave up and just switched to c++ for this lesson but in the end i prevailed! i ended up learning a bit about how these motors work (or at least how to control them electronically) and writing my own motor controller class after i wasn't able to find any that behaved exactly how i wanted. i think my controller class is kind of specific to the uln2003 motor driver, but that's ok it also took me far longer than it should have to realize that i needed to change my loop behavior from full rotations to one step at a time in order to incorporate the button press being at any time!
@donthomas9669
@donthomas9669 4 жыл бұрын
I got it on my OWN!!! My confidence is growing!! Thank you so much Paul, you are an excellent teacher, and the best part of my day is coming home and doing these arduino tutorials with you, I look forward to them all day long. I used an if else statement, with a button value variable and a digitalRead command making the button HIGH with a digitalWrite command.I didnt even use buttonValNew or buttonValOld, I just used button val and I used If(buttonvalue==0) then the stepper commands, then else (buttonvalue==1) then the negative stepper commands.
@mrsquiggles1379
@mrsquiggles1379 4 жыл бұрын
Did it almost exactly the way you did it. Only difference is I use bool instead of int for the clockwise variable. I understand c++ very well just not the electronics so much. Really appreciate all you do I have learned so much.
@ricardomoreira7447
@ricardomoreira7447 3 жыл бұрын
I did on my own but used the if and else statements .then used ur idea to end the project.👏
@md.mizanurrahman5852
@md.mizanurrahman5852 Жыл бұрын
Dear Paul, Thank you for nice tutorial. I have done one on my own in harder way but after following your tutorial I made it easier.
@leokim6831
@leokim6831 4 жыл бұрын
This is the best channel on youtube I hope that I have a teacher like you in my school
@muhammadrafiqulislamkhan6994
@muhammadrafiqulislamkhan6994 2 жыл бұрын
Magic. I am learning from you. Hope I can able to do my own whithout taking any help from you but now I can not do without your support. Thank you.
@christopheraguilar44
@christopheraguilar44 4 жыл бұрын
I was soooo worried my motor didn't work BUT I followed the troubleshooting steps you showed us in all your previous videos and it turned out it I was given a dud for a battery in my shipment! Thanks for the very beneficial videos you put out ive learned so much during quarantine!
@MarvPerk3
@MarvPerk3 3 жыл бұрын
Hi, Paul, I did do this on my own first... but struggled mightily with it for about 4 hours, and ended up with code that was much more complicated and less elegant than yours! It got the job done, I won't bore you with my convoluted code, but what i didn't do was dynamically set the state and rule out buttonVal of 1 all in one shot at the digitalRead of the button, nor did I realize that you could ignore starting a full revolution, but just base it all on one step, looping continuously until the button read got a zero value. So I ended up with multiple nested for loops, returns if the button state had changed, and one set of nested "for"s for one direction and another set "for"s the other direction, with button reads and check for a change in each! I suspected I was doing it with way too much code/complexity, but since I got it to work flawlessly at least, it was only after that that I went on to see what you did. ...and hence learned a lot more! Even though I struggled and ended up with a solution that was cumbersome, I still learned a lot by both working through my approach until it worked and then seeing your much more efficient and creative solution, so thanks, and thanks for always encouraging us to try to work them out ourselves first!
@johnplowright6421
@johnplowright6421 5 жыл бұрын
Great lesson, for my "Homework" I got the change of direction but the motor only did one rotation then waited for a button press to start in the next direction. for my pinMode I use pinMode (buttonInput, INPUT_PULLUP); which work the same as your digiatlWrite method.
@shatterism3329
@shatterism3329 Жыл бұрын
I did it in a different way and used a boolean value. This homework is challenging for me and took me 4 hours (with some momentary breaks) but enjoyed the process. Thank you Paul for teaching me how to use the Arduino. Actually I bought the kit on January and looking for tutorials but I was so hesitant to watch yours because I want to literally go straight up making cool and perplexing projects. I gave up because I don't understand anything. From why is the LED hooked that way and why it has a resistor. Why does the breadboard has + and - rails. Why do you do pinMode in the void setup and digitalWrite in the void loop, and literally everything else. I felt that this isn't for me even though my long-time dream is to work in the robotics field (still my dream as of now). I figured out the reason why it was hard. It's because I immediately jumped to the best part where you apply everything you learn (which for me, none) to make those cool projects. Just like how everyone wants to be like Elon Musk but no one wants to work hard like him. Anyways, this thought of mine lasted until May (4 months after buying the kit). I again saw your tutorials and somehow thought of watching everything, because suddenly I get the feeling that I want to learn. Now I can apply what you taught us from Lesson 1-35 and still ongoing and looking forward to finish this tutorial. Thinking of watching your tutorial is one of the best blessing I got so far in my life. Sorry if this comment is too long. It's okay if you don't want to read it. I just want you to know that I made it this far and you are a big part of it. I'm still working with my dream. Thank you!!!
@MardinBodley
@MardinBodley 2 ай бұрын
Done this on my own but used parts of lesson 28 the toggle switch on the leading edge. Using the if and else loops. But will now study your version.
@theknottyworkshopgeoffjung529
@theknottyworkshopgeoffjung529 4 жыл бұрын
I gave it the old college try, but was unable to make it work all the way. I did use the -1, but then I used an "else" and multiplied by 1, and that was the issue. Thanks for the videos!
@gimmeair57
@gimmeair57 4 жыл бұрын
Good one coach. I was stepping back & forth while holding the button. Went back and changed it so now works as required. Happy to say I did use the -1 trick :- )
@flyboypat
@flyboypat 2 жыл бұрын
ordered my kit finally, with your link. I have a different kit that doesn't have all the same components. This is a great series. Thanks for taking your time Paul.
@iPhonePhixer
@iPhonePhixer 2 жыл бұрын
Thanks for the great videos, I always watch them until the end. Yang Chen is right, I was able to power everything by using a 5V rail. What really cooked my noodle was I could not get my motor to reverse. It took me a few minutes, I check my code over and over, even changed the negative values and nothing seemed to work. Then, I switched the two center wires on the step motor and viola, it all worked as expected. This is also how I came to find out that you can use the 5V power source. My motors didn't work at first, but when I change the "motospeed" to 3, it worked.
@michaelpage4043
@michaelpage4043 2 жыл бұрын
I had the same problem with the motor not running backwards so as you suggested I changed the two center wires and it worked. I guess the two electro magnets were mapped differently for our step motor. Thanks for the post.
@dancorwin9232
@dancorwin9232 2 жыл бұрын
holy crap thank you!! I was having the same problem both with the power supply and the motor not reversing properly
@coollegooli9805
@coollegooli9805 4 жыл бұрын
I did it on my own. However, i did it a little bit different, so that my switch toggles when i let go and not when i press down, other than that it does excactly the same, just a little bit more complicated code. THANK YOU for these turtorials, i have watched every single one up until this one over the last couple of weeks, great learning from a great teacher :)
@katherineclarke4435
@katherineclarke4435 3 жыл бұрын
I didn't manage to do it all on my own. I wrote it out in English not code and I knew there was something that needed to be multiplied by -1, just couldn't work out what!! Good project, thanks!
Arduino Tutorial 37: Understanding How to Control DC Motors in Projects
31:25
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
Beginners Guide To Using Large Stepper Motors: #087
19:49
Jeremy Fielding
Рет қаралды 299 М.
How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples
44:13
Stepper Motors with Arduino - Controlling Bipolar & Unipolar stepper motors
50:22
Arduino Tutorial 34: Simplest Way to Use a Pushbutton Switch
10:26
Paul McWhorter
Рет қаралды 102 М.
Stepper Motors and Arduino - The Ultimate Guide
29:57
How To Mechatronics
Рет қаралды 1,2 МЛН
Big Stepper Motors with Arduino
29:43
DroneBot Workshop
Рет қаралды 1,2 МЛН
Electronic Basics #24: Stepper Motors and how to use them
6:47
GreatScott!
Рет қаралды 2,2 МЛН
Control Stepper Motor Speed & Direction with Arduino and a Potentiometer
13:18