// sketch.ino
// Isolated test loop for the Electromagnet module.
#include "electromagnet.h"
// We use Pin 6 for this test so we don't interfere with your Pin 2 Stepper button
const int magnetButtonPin = 6;
void setup() {
Serial.begin(115200);
pinMode(magnetButtonPin, INPUT_PULLUP);
setupElectromagnet();
Serial.println("--- Electromagnet Test Ready ---");
Serial.println("Press Bare Button (Pin 6) to trigger cycle.");
}
void loop() {
// Because it is wired straight to GND, pressing it sends a LOW signal
if (digitalRead(magnetButtonPin) == LOW) {
Serial.println("\n>> Cycle Triggered");
activateMagnet(); // Executes the full ON -> WAIT -> OFF sequence
Serial.println(">> Cycle Complete. Waiting for next input.");
// Hardware debounce: Wait a moment for the button spring to settle
delay(50);
// Safety pause: Do nothing as long as the user is holding the button down
while(digitalRead(magnetButtonPin) == LOW);
}
}Start Sorting
Calibrate
Limit Switch