I have a small bipolar stepper (like a head motor in a floppy drive) being driven by a DRV8834 board (the low voltage brother to A4988). I’ve made a simple sketch to test the principle of running the motor one way upon the press of a momentary switch, then back again on a second press. If I take out the button components of the sketch, I can make the motor run back and forth endlessly, so the stepper hardware is doing it’s job. Similarly, I can make a separate sketch of the button doing it’s thing, toggling an LED on and off. But when I try to marry the two, the motor just sits there doing nothing (although it feels energised). I’ve tried ‘for/else’ loops, boolean and just integers for the button state and stepper state. At one point I did get a button press to run the motor out and back , but that isn’t what I need. Press (1) - motor out. Press (2) - motor in. Return to beginning. Couldn’t be more simple, could it?
Can someone with more experience cast an eye over my code and tell me where my logic is failing please?
Stepper_Test.ino (1.69 KB)