so i recently got an arduino micro for a project needing the control of two stepper motors with the A4988 driver. previously i was prototyping on an arduino uno and everything was working fine, but on the switch to the micro the motors started behaving erratically such as random step direction and a random number of steps being taken. i've pretty confidently narrowed it down to the output pins floating, i've recorded the direction pin on the micro floating with ~2v being "off" and ~3v being "on" with a multimeter. the thing is is that i can't find anything about fixing this other than doing.
pinMode(DIR, OUTPUT);
digitalWrite(DIR, HIGH);
or external pull resistors and i've tried both pull up and down resistors at 100k and 330 ohm with no luck.
right now i have one motor connected to uno and one to the micro, the motor on the uno still runs fine with no external pull resistors. the below schematic shows a simplified version of how both the uno and the micro are wired.
simulate this circuit – Schematic created using CircuitLab
and here is the code both arduinos are running.
#include "A4988.h"
#define MOTOR_STEPS 200
#define DIR 10
#define STEP 9
A4988 stepper(MOTOR_STEPS, DIR, STEP);
void setup() {
pinMode(DIR, OUTPUT);
digitalWrite(DIR, HIGH);
pinMode(STEP, OUTPUT);
digitalWrite(STEP, HIGH);
stepper.setRPM(100);
}
void loop() {
stepper.rotate(360);
delay(1000);
stepper.rotate(-360);
delay(1000);
}
here are some links to other related post https://stackoverflow.com/questions/14174162/arduino-micro-triggering-with-no-contact https://forum.arduino.cc/t/high-impedance-output-pin/655236