I am trying to program a stepper to reverse direction after a micro switch is activated. I believe I'm very close, but not close enough. I'm now stumped. See each code attached.
change_mod is simply a modified code for latching a micros witch. It works perfectly.
Stepper_with_micro_TEST is a debounce, stepper code spliced with the change_mod code. It should work as well. BUT, it doesn't
I isolated the problem to the if statement. ..........if ( debouncer.fell() )
If this line is omitted, the program runs without any micro switch function. No errors in code.
BTW, thank you for your quick response. Some more info. I think the state of pin 2 should be low according to the code. After code is uploaded to the board, I measured the voltage between pin 2 and ground to be 5V. If I press the micro switch, pin 2 goes low, but the motor still doesn't run and pin 2 doesn't latch.
Note: change_mod does latch and work for an LED. Both codes are identical except for one thing........
Stepper micro TEST code has three pins and code for a stepper motor vs. LED.
Also note I've verified the stepper motor code is good and works by itself.
paloian:
BTW, thank you for your quick response. Some more info. I think the state of pin 2 should be low according to the code. After code is uploaded to the board, I measured the voltage between pin 2 and ground to be 5V. If I press the micro switch, pin 2 goes low, but the motor still doesn't run and pin 2 doesn't latch.
Note: change_mod does latch and work for an LED. Both codes are identical except for one thing........
Stepper micro TEST code has three pins and code for a stepper motor vs. LED.
Also note I've verified the stepper motor code is good and works by itself.
Thanks again
you aren't trying to power your servo with the output from the Arduino pins, right?
Why does the change_mod code (written for LED) latch the MS(micro swtich) and it won't latch the MS when slightly modified for a stepper? both code are virtually identical.
I partially understand. However, based on your reply, this will never work. I've read about counters, boolean commands and a few other techniques to latch the MS state. I haven't found one that works properly.