Firmware flow
Repeat a coordinated two-servo sweep
Selected runServoSequence implementation.
Each cycle commands both servo outputs during an upward sweep and a downward sweep. A busy-wait follows each step. After four cycles, both outputs are commanded back to zero.
The code blocks during its busy-waits. The diagram describes servo commands and repetition, not measured servo motion or timing accuracy.
Read the implementation
Selected firmware excerpt. The diagram explains the code; it is not a hardware test.
The unchanged excerpt shows the return sweep. The flow follows the complete reviewed runServoSequence implementation at lines 59–93.
Selected return-sweep loop from the four-cycle routine
for (int pos = 60; pos >= 0; pos--) {
servo1.write(pos);
int pos2 = map(pos, 0, 60, 0, 20);
servo2.write(pos2);
unsigned long tStart = millis();
while (millis() - tStart < stepDelay) {
// Non-blocking wait
}
}Technical notes
A defined movement sequence
runServoSequence() maps the first servo's 0–60 range to the second servo's 0–20 range. It repeats the outward and return sweeps four times, then commands both outputs to zero.
Trigger and cooldown
The main loop starts the sequence when the PIR input is high and the three-second cooldown has elapsed. It switches an LED on during the sequence and records completion before accepting another trigger.
Blocking step timing
Each step uses a busy-wait, so the main loop is blocked while the sequence runs. The displayed return-loop comment calls this non-blocking, but the implementation waits in place. These are commanded angles, not verified physical positions; no UART command task is implemented.