How to program stepped motor

Hello everyone, I am learning (and teaching my 13 years old son) Arduino and programming. We were able to make the stepped motor work with the attached code i got off youtube. But for our project we need the motor to to turn 90 degrees and return to original position. How to code this for the Arduino UNO? (using UNL2003 controller and the motor is 28 BYJ).

Thank you for helping us.

Andre
Hi every

Stepped_motor_V1.ino (1.88 KB)

How will you trigger the move?

It looks like the hard work has been done for you. Try a for loop to call OneStep sixteen times passing it false. Then do it again passing true. Delay for a bit to observe whether it worked.

You will likely need to delay between steps too.

andre757:
Thank you for helping us.

It will be much easier to help you if you include your short program in your Post so we don't have to download it. See How to get the best out of the Forum

...R

Hi Andre,

with grabbing one youtube-video about the subject you want to learn
you can have luck - or not.

The program works. And it is the right step to ask questions.
Making this stepper-motor move is a quick success. That's OK for me.
Anyway to really enjoy programming in the long run is to understand what is going on.

The code has no comments. Easy to understand comments is one criteria for a good program.
I suggest doing a mixture between quick successes and deeper learning.

Here is a tutorial that covers the basics.
It is not sensational in the sense of

  • download code from internet
  • upload to your arduino
  • light-show wins every competetion.

It is showing and explaining important things.
Learning to program
https://startingelectronics.org/software/arduino/learn-to-program-course/

another way would be to look up the used functions inside the stepper-code
The Arduino-IDE has a reference offline on your harddisk and online here on arduino.cc

So simply go reference Arduino Reference - Arduino Reference

and search for each function to read the explanation of the reference
first one is pinMode

https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/

Whenever you have concrete questions most users here enjoy answering concrete questions.
best regards Stefan

Thank you for your suggestions.