I have a little problem with controlling stepper motor (NEMA 17).
I use: Arduino MEGA2560, A4988 controller, 5X4 matrix keypad.
The project contains other tasks I just talk about the stepper section. The task is following: If I push button 'A' the stepper starts revolve CW direction, if I push button 'S' the stepper stops revolve, if I push button 'B' the stepper starts revolve CCW direction. So... If I push the dedicated buttons on keypad the stepper should start revolves CW or CCW or stop. In the sketch I use 'for loop' (I found this on internet. I try it with do-while, but the issue is the same). so far it works properly. when I push one of trigger button (‘A’ or ‘B’) the motor starts revolve, but... my big problem that is I can not stop the stepper before the loop end. I can't intervene to loop (Arduino not receive any inputs from keypad) while it is running. I know there exist interrupt methods for every microcontroller, but I want to use the matrix keypad for this process and not an external button. Could someone advise? Can I somehow intervene in 'for loop' via matrix keypad?