My son got a project at school to control a stepper motor with three buttons and a limit switch.
Since we do not understand Arduino programming and writing code. we need help
Project description:
When you hold down one button, the motor goes in one direction.
But if the limit switch is activated, the engine should stop.
When he holds down the second button, the motor goes in the opposite direction, and if the limit switch is activated, the motor stops.
When the third Button is pressed and the motor is released, it goes in one direction regardless of whether it goes CW or CCW until it activates the limit switch and then it stops and returns in a few circles back in the opposite direction from the original
Every time the limit switch is activated, the function of the button is switched off, the motor stops and a certain number of circles must be returned in the opposite direction.
That motor shield is very old. I think it was the start of the Adafruit company. It is only for 12V DC toy motors.
Do you have the specifications of the stepper motor ?
I suggest to try a few things. Make a number of test sketches.
For example a sketch that reads a button and shows it to the serial monitor.
Arduino has a Stepper library, but that is not for a driver module with DIR and STEP. There is a AccelStepper library that can use the DIR and STEP signals of many driver modules. The AccelStepper library is beautiful in its simplicity. It does not use interrupts, and a delay() in the sketch could cause a hiccup in the stepper motor.
It depends on the type of stepper motor and the driver board that you use which library is the best.
To stop at the limit switch while a button is pressed, you have to let the Arduino loop() function run as much as possible. That requires a certain way of thinking. It is like running in circles and looking at buttons to check if something needs to be done. Don't stop running in circles to wait for the button to be released.
We also have an Arduino CNC shield that was on some CNC laser that we bought a long time ago and it uses GRBL some code and it controlled 3 of these no 17 step motors.
Maybe he can be used.
We know nothing about coding and writing code, the scheme of connecting components. But we can connect and load the code that's what we did with those ready-made projects to turn on the leds through the button, those IR diodes to print the text we give it when it breaks... and so some small things that we found ready with a schematic and code .
Those are not toy motors. The Nema 17 is often combined with a DRV8825 or a A4988 driver module. Not all Nema 17 motors are the same. Some are 3V 2.5A and others are 12V 350mA.
I think you can put that motor shield V1 aside.
You have already done some learning projects ? That is good But you need to learn what the code does. We are not writing the sketch for you.
Can you read three buttons and show the result on the Serial Monitor ?
Start here: digitalRead() - Arduino Reference
Adding a CNC shield and control it via GRBL makes the project more complex. Are there driver modules on top of that CNC shield ? Perhaps A4988 drivers ?