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.
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 :)
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.
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.
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!
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. 👍
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.
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!
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!
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!
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.
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.
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.)
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.
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.
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!
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.
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.
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!
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.
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!
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....)
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!
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.
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.
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...
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!
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)
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.
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. :)
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.
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.
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!
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.
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
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.
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!
Nice troubleshooting. Always suspect bad connections and batteries before anything else. Seems the components themselves are rarely the culprit. Thanks for the comment.
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.
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.
@@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); } }
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.
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!
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!!!
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.
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!
You accuse some of us of watching without doing the homework? The way I learn is watching through the series to absorb the concepts. After 35 video's watched and 33 to go I will watch through the second time with the hands on approach. Thank you for your contributions. :-) BTW My knowledge and skills with Fusion 360 have become more advanced thanks to your Fusion series
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.
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.
Paul keeps saying that we should have learned these things a long time ago, but I'm learning as a 10 year old! I gotta say Paul, you really have mastered teaching all ages. This set of tutorials are easy to understand, but so, so useful. Thanks. I finally found something useful to do during COVID-19.
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.
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?
Ever have all the confidence in the world and fall flat on your face :) I didn't get the homework and am thinking about binge watching all videos from scratch to fill in any gaps I have in my brain housing group. Excellent video.
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!
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!!
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.
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.
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 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.
I enjoy all tutorials and will keep on doing as well as I can homeworks. I haven't succeeded the program. It's nice to "see" what's going on at pin 8, 9, 10, 11 with oscilloscope and see nice square waves. You're the teacher I needed when I was at high school 55 years ago. Thanks for all.
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.
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.
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
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!
I don't usually comment but I feel like I have to this time. I was pulling my hair out trying to figure out why my homework wasn't working. Everything seemed fine but the stepper wasn't turning no matter what I tried. After about an hour I finally realized that I forgot to plug the psu into the battery 🤣. I now have everything working. Thanks Paul!
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.
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.
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 :- )
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.
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.
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.
I see that you used the main loop i.e. the void loop() as the "looping clause". I did mine using 4 WHILE loops. It works the same! My brain is kinda wired to using WHILE loops ever since Arduino Tutorial 17. It just seems natural to me. Also, I observed that using 4 WHILE loops lessen the need to declare additional variables other than buttonPin and buttonVal. For me, it's easier to understand/troubleshoot this way. But to each his own i guess, our brains are wired differently and so our logical thinking. No code is bad as long as you can understand it on your own and troubleshoot. Another great lesson Sir Paul! Thank you for this : D
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!
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.
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.
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.
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.
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 :)
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.
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
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!
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.
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 :)
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.
was the new battery any different?
Yep, me too. Mine came with a Piscell 9V: obviously not up to the task. Energiser did the trick!
same
Even with a brand new battery it's weak. Can't beat a power supply
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.
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!
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. 👍
SOOO TRUU BRO!!
Exactly 👌
You, sir, are the Bob Ross of engineering. Thank you for your great tutorials.
so on point! stealing this since I tell so many people about him :)
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.
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!
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!
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!
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.
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.
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.)
GIDDY UP. ok this dude rules. going back to the beginning and watching all of these because he's an awesome teacher!
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.
Thank you friend 🥳
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.
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.
The stepper motor has 4 coils each coil is connected to 5v through these pins.
@@jafaralturfy5053 thanks mate
@@misterdecaro I believe this is just due to the ribbon cable and wanting to put them in order physically on the connectors.
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!
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.
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.
Sorry, super late reply, but decrease the amount of steps between each check. Heck, you can have it check after every 1 step.
Unable to complete the homework on my own but grateful for the lesson! Thank you Paul!
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.
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!
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.
same here. Luckily I found the culprit with a voltmeter
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!
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....)
thanks man I think I have the same issue lol
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!
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.
I wish that all TH-camrs had your ability to understand a student’s perspective and have the ability to thoroughly teach every step in the process.
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!!!
Hi could you please send me your work to wrekjohn@gmail.com
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.
Excellent!
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...
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!
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?
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)
Thanks, i need to switch batteries then
it worked thanks.
Thank you for suggesting this.
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.
I did it on my own, but made it way too complex. Thanks for the great lesson Paul. Much love.
Mr Paul, your tutorials are really interesting and educative, breaking down every little detail. Thumbs up for the good job.
Glad you like them!
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.
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. :)
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.
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.
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.
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
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.
These lessons are making me think hard but that's good for my old age
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!
I did this one on my own, but wow did I overcomplicate it.
i did this and i undercomplicatet it
you dont even need buttonval old
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.
My battery died almost immediately. Lucky you warned us so we didnt panic and measured the voltage to confirm.
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.
@@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
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.
the elgo driver does not work some times unless you switch IN1 with IN4 .
That's right! How'd you figure that out?
thank you bro you saved me hours of trouble shooting
Wow what a life saver..... I wish Paul would have mentioned that... Thanks a lot by the way.... Because the stepper motor was misbehaving
Well it didn't work too
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
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.
Yeah, I did it by using different logic!
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!
Nice troubleshooting. Always suspect bad connections and batteries before anything else. Seems the components themselves are rarely the culprit. Thanks for the comment.
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.
me too
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.
@@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);
}
}
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.
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!
THANK YOU! I've been trying to figure this out for an hour
Thank you, good sir! I guess I must be dyslexic
"Stepping" up the difficulty I see! This lesson was a "stepping" stone, one might say. Oops! Sorry, looks like I "overstepped" my limits here. 😶😍
You, sir, have earned my respect.
MotiOnTech , You have taken a step in a right direction but now you must step back.
You should be removed from this channel, that'll servo right.
you need to step off with all these puns!
No you didn't, you are just getting started
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!!!
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.
You are probably running more current in the components that you should be doing and that is why it’s heating up
So glad I read the comments. My motor would only spin one direction until I switched pins 2 and 3 on the motor controller.
21:52 this is everyones reaction when their first line of code works! P A S S I O N!!!
dang thats some passion!
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.
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!
You accuse some of us of watching without doing the homework? The way I learn is watching through the series to absorb the concepts. After 35 video's watched and 33 to go I will watch through the second time with the hands on approach. Thank you for your contributions. :-)
BTW My knowledge and skills with Fusion 360 have become more advanced thanks to your Fusion series
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.
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.
This series is still relevant today. I've learned so much going back to the basics. Thank you very much Paul.
Paul keeps saying that we should have learned these things a long time ago, but I'm learning as a 10 year old! I gotta say Paul, you really have mastered teaching all ages. This set of tutorials are easy to understand, but so, so useful. Thanks. I finally found something useful to do during COVID-19.
The only thing that I'm having trouble with is the math, but that is understandable too!
UwU
That's great!
Thanks so much for the tutorials!
This is the best channel on youtube I hope that I have a teacher like you in my school
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.
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?
Ever have all the confidence in the world and fall flat on your face :) I didn't get the homework and am thinking about binge watching all videos from scratch to fill in any gaps I have in my brain housing group. Excellent video.
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!
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!!
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.
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.
Great job!
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?
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
@@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.
I enjoy all tutorials and will keep on doing as well as I can homeworks. I haven't succeeded the program. It's nice to "see" what's going on at pin 8, 9, 10, 11 with oscilloscope and see nice square waves. You're the teacher I needed when I was at high school 55 years ago. Thanks for all.
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.
Excellent!
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.
Was able to almost complete homework. My stepper would not change directions until completion of the revolution cycle. Great Lesson again Sir.
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
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!
I don't usually comment but I feel like I have to this time. I was pulling my hair out trying to figure out why my homework wasn't working. Everything seemed fine but the stepper wasn't turning no matter what I tried. After about an hour I finally realized that I forgot to plug the psu into the battery 🤣. I now have everything working. Thanks Paul!
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.
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.
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 :- )
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.
you are the best teacher i ever seen my life...
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.
I did Tutorial 35, and did it differently than you did. I liked your coding much better. Thanks for a great series.
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.
The battery is useless. Lasts about 10 seconds.
I see that you used the main loop i.e. the void loop() as the "looping clause".
I did mine using 4 WHILE loops. It works the same!
My brain is kinda wired to using WHILE loops ever since Arduino Tutorial 17.
It just seems natural to me.
Also, I observed that using 4 WHILE loops lessen the need to declare additional variables other than buttonPin and buttonVal. For me, it's easier to understand/troubleshoot this way. But to each his own i guess, our brains are wired differently and so our logical thinking.
No code is bad as long as you can understand it on your own and troubleshoot.
Another great lesson Sir Paul! Thank you for this : D
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!
This is just a brilliant series Paul, I am having so much fun learning this stuff. Thank you so much!
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.
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.
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.
holy crap thank you!! I was having the same problem both with the power supply and the motor not reversing properly
I studied at the university about arduino, but just now I am really learning.
Thanks Paul, quite relaxed arduino lessons!!!!
Glad to help!
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.
Was able to do it on my own but your use of 1 and -1 for the toggling is more clever than my solution which used a boolean variable! Thanks again.
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 :)
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.
Thank you so much for this video! I hope it reaches many other people
Me too!
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
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.
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!
I did my homework honest but the dog ate it! Enjoying making things move, thank you again sir.