The Stepper motor works when I test it with a simple sketch (Nema 42 using a Microstep Driver DM556S). The Hall Effect Switches works when I test them with a simple sketch, but if I power on the stepper motor's power supply the interrupts immediately gets triggered. As a newby this is really confusing me. Attached is an image of the layout and the code will follow.
With the power to the stepper motor OFF and running the sketch I get "Triggered" when the magnet moves over the Hall Effect Switches. The moment I turn on the power to the stepper motor I just get an endless loop of "Triggered" in the serial monitor.
Code: Untitled.cpp Select all
const byte RightHallPin = 33;
const byte LeftHallPin = 32;
void setup() {
Serial.begin(115200);
pinMode(LeftHallPin, INPUT_PULLUP);
pinMode(RightHallPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(LeftHallPin), chgdir, RISING);
attachInterrupt(digitalPinToInterrupt(RightHallPin), chgdir, RISING);
Serial.println("Initialised");
}
void chgdir() {
Serial.println("Triggered");
}
void loop() {
delay(1);
}
