One turn and back
Arduino C++Full step, MS pins open. Turn the shaft exactly one turn forward (DIR on D4 HIGH, 200 pulses on D3, 2500 µs high and 2500 µs low each), print "one turn", wait 500 ms, then set DIR LOW and step 200 pulses back to where it started and print "home".
Checks
- Not run yetRuns for 3 s
- Not run yetDIR (D4) is HIGH on the way out
- Not run yetSTEP (D3) pulses every 5 ms, about 400 times
- Not run yetPrints "one turn" after the first second
- Not run yetDIR is LOW on the way back
- Not run yetPrints "home"
Hints
- 200 full steps of 1.8° make 360°. Each pulse: digitalWrite(STEP, HIGH); delayMicroseconds(2500); digitalWrite(STEP, LOW); delayMicroseconds(2500);
- Put the pulse loop in a function, steps(int n), and call it twice.
- Change DIR between the two moves, before the first pulse of the way back.