// sketch.ino
// Isolated test loop for the Rotation Servo module.
#include "rotation_servo.h"
const int testButtonPin = 6;
// Logic flag to track the current position of the arm
bool isAtHome = true;
void setup() {
Serial.begin(115200);
pinMode(testButtonPin, INPUT_PULLUP); // Bare button connected to GND
setupRotationServo(); // Initializes Pin 10 and moves to 0 degrees
Serial.println("--- Rotation Servo Test Ready ---");
Serial.println("Press Bare Button (Pin 6) to toggle arm position.");
delay(200); // Hardware stabilization delay
}
void loop() {
if (digitalRead(testButtonPin) == LOW) {
Serial.println("\n>> Toggle Triggered");
// Check where the arm is, and move it to the opposite position
if (isAtHome == true) {
moveArmToBin();
isAtHome = false; // Update location status
}
else {
moveArmToHome();
isAtHome = true; // Update location status
}
Serial.println(">> Movement Complete. Waiting for next input.");
// Hardware debounce and wait for button release
delay(50);
while(digitalRead(testButtonPin) == LOW);
}
}Start Sorting
Calibrate
Limit Switch