// sketch.ino
// Isolated test loop for the Tray Servo module (Residue Dump Sequence).
#include "tray_servo.h"
const int testButtonPin = 6;
void setup() {
Serial.begin(115200);
pinMode(testButtonPin, INPUT_PULLUP); // Bare button connected to GND
setupTrayServo(); // Initializes Pin 11 and sets tray to horizontal (0 degrees)
Serial.println("--- Tray Servo Test Ready ---");
Serial.println("Press Button (Pin 6) to trigger the residue dump sequence.");
delay(200); // Hardware stabilization delay
}
void loop() {
if (digitalRead(testButtonPin) == LOW) {
Serial.println("\n>> Dump Sequence Triggered");
Serial.println("Opening tray to 90 degrees...");
openTray();
// 3-second placeholder delay to allow non-magnetic scrap to fall into Bin 2
delay(3000);
Serial.println("Closing tray back to home position (0 degrees)...");
closeTray();
Serial.println(">> Sequence Complete. Waiting for next input.");
// Hardware debounce and wait for button release
delay(50);
while(digitalRead(testButtonPin) == LOW);
}
}Start Sorting
Calibrate
Limit Switch
Electromagnet