I'm trying to control a stepper motor (Nema 17) using a Mega 2560 and a DQ542MA microstep driver.
I found some examples that look straightforward enough but I can't seem to get them to work on my Arduino exa link.
When I check the output voltages on my stepPin, I only see 2.5V instead of the nearly 5V I'd expect.
Here's my code:
int stepPin = 26;
int dirPin = 28;
int enblPin = 32;
void setup() {
pinMode (stepPin, OUTPUT);
pinMode (dirPin, OUTPUT);
pinMode (enblPin, OUTPUT);
digitalWrite(stepPin, LOW);
delayMicroseconds(4000);
digitalWrite(dirPin, LOW);
digitalWrite(enblPin, HIGH);
}
void loop() {
delayMicroseconds(4000);
digitalWrite(stepPin, HIGH);
delayMicroseconds(4000);
digitalWrite(stepPin, LOW);
}
What's strange is that when I check the voltages of the dirPin and enblPin, I see 5V when they're set HIGH.
I only see this weird behavior when stepPin gets "set to LOW after being set to HIGH inside the void loop()". Time between switching from HIGH to LOW doesn't matter... i've had it from 100ms to 4sec as seen in the code above.
The other output pins all get set to HIGH (5V) properly by this code.
It's almost like the internal pull-up isn't getting set correctly but changing the pin doesn't matter ...
Any ideas?
**EDIT: **
I figured it out ... delay() vs delayMicroseconds() ... of course I wouldn't see it ... it was flipping too fast for me to read with my DMM ...