April 2024. A laptop runs YOLOv5 on a webcam, finds a bottle, and remembers where it sat still for three seconds. Move the camera away and an Arduino lights the way back: red for left, green for right, white for up, blue for down, and a buzzer when you’re within ±50 px.
It worked on my desk. That was the extent of the evidence then: a demonstration, not a measurement of how quickly or reliably someone could return to the target. The laptop did not move the camera. I did.
That small distinction changes the project. The detector is the sensor, the LEDs are a display, the person supplies both the interpretation and the motion. I had built part of a control loop, then let the operator quietly supply the parts I had not designed. Looking back at this alongside the later vehicle work is more useful than pretending it was an early autonomous robot.
What the camera remembers
The reference is an image position, not a place in the room. If a detected bottle has box corners (x₁, y₁) and (x₂, y₂), its centre is ((x₁ + x₂)/2, (y₁ + y₂)/2). Compare that centre with the stored reference and there are two errors: horizontal and vertical.
This is enough to say which way the target appears to have moved. It does not recover the camera’s position, the bottle’s distance, or a three-dimensional trajectory. Moving the bottle can change the same image coordinates as moving the camera. A larger bounding box is not, by itself, a calibrated range measurement.
The original ±50 px acceptance zone is a square in image coordinates: both errors must be inside their limits. It is not a 50 px radius. The distinction matters near a corner, where each coordinate can be acceptable even though the distance from the centre exceeds 50 px.
Four on/off indicators can communicate direction, including a diagonal through two lights at once. They do not communicate how much motion is left. A target 51 px away and one 200 px away produce the same instruction. The hardware did not prohibit a richer signal; the binary display policy did.
Regrading a desk demonstration
In 2026 I returned to the rig as a human-in-the-loop study. There were no recruited participants and no measured reaction-time distribution. The “person” in the plots is a deliberately simple model, whose assumptions can be read and changed in fourleds/run.py:
- 250 ms reaction delay. A command is acted on 25 simulation steps after it is displayed.
- 600 px/s maximum motion. This is image-space speed, not a measured hand speed or a speed in metres per second.
- 10 ms integration steps. Each trial lasts eight seconds, with Gaussian velocity noise of standard deviation 25 px/s added separately on both axes at each step.
- Random starts. Each coordinate begins uniformly between −220 and +220 px. There are 200 trials at each zone size; each display mode starts its random generator from seed
2024. - Held detections. The LEDs retain the last observation between detection updates. The source requests 15 Hz, but
int(1 / 15 / 0.01)gives six steps: the implemented period is 60 ms, or about 16.67 Hz. The archived plots include that rounding, not an exact 15 Hz sensor.
The two policies get the same motion limit, reaction delay and noise model. The on/off policy asks for full speed whenever an axis is outside the zone. The proportional policy scales the command with error, reaching full brightness at four times the zone half-width. Inside the zone, either policy switches that axis off.
That is a comparison of display policies under these assumptions, not a finding that real people behave like delayed motors.

What “settled” actually means
The scorer looks at both axes. A trial succeeds only if it spends at least the final second of its eight-second run inside the acceptance square. Its settling time is the first step after the last excursion outside. A brief pass through the centre does not count.
| Zone half-width | On/off: failed within 8 s | Dimmed: failed within 8 s | Dimmed: median among successes |
|---|---|---|---|
| ±10 px | 100.0 % | 100.0 % | No successes |
| ±20 px | 99.5 % | 99.5 % | 0.00 s, one success |
| ±30 px | 97.5 % | 6.5 % | 3.34 s |
| ±40 px | 97.5 % | 2.5 % | 1.11 s |
| ±50 px, the 2024 setting | 95.5 % | 2.0 % | 1.04 s |
| ±75 px | 81.0 % | 0.0 % | 0.52 s |
| ±100 px | 0.5 % | 0.5 % | 0.50 s |
The ±20 px row is a good warning about reporting a median without its denominator. The sole successful dimmed trial has a settling time of zero: it begins inside and never needs to leave. That is not evidence of an extraordinarily fast controller. At ±30 px the successful trials take longer, yet the display is much more useful because almost all the trials succeed.
Likewise, “failed within eight seconds” does not mean “can never settle.” The run is finite. A zero observed failure rate in 200 trials is not a guarantee either; a different seed, motion model or starting distribution can change it. The small reversal between the ±75 and ±100 px rows is another reason not to turn the table into a universal law.
Why the indicator hunts
Before changing a neural network, the arithmetic is worth doing. At 600 px/s with a 250 ms delay, motion continues for roughly 150 px after the display changes and before the model responds. The original acceptance zone is only 100 px wide.
So the model can cross the whole zone while still carrying out the instruction that brought it there. The next observation asks for the opposite direction, but that instruction also arrives late. A bang-bang display has supplied a sign without supplying a braking policy.

The demonstration worked with a person in the loop. It did not establish that the display had taught the person how to slow down.
The estimate distance ≈ speed × delay is intentionally rough. Sampling adds another wait; the hand model is not a real wrist; camera motion does not always translate to a constant pixel speed. Its value is diagnostic: the missing time scale is already large enough to explain why simply following the lights can overshoot.
Why dimming helps, until it doesn’t
In the model, a dimmer light means a smaller commanded speed. Near the target, the proportional policy is approximately velocity = −K × delayed_error. With maximum speed 600 px/s and a full-brightness ramp of 4b pixels, where b is the zone half-width, the effective gain is K = 600 / (4b) per second.
At b = 50 px, that gain is 3 s⁻¹. At b = 20 px, it is 7.5 s⁻¹. Tightening the zone has not merely demanded more precision: this implementation has also made the response more aggressive.
A useful reference is the ideal continuous delayed loop ė(t) = −K e(t − τ). Try an exponential solution and its characteristic equation is s + K exp(−sτ) = 0. At the first imaginary-axis crossing, setting s = jω gives:
K cos(ωτ) = 0
ω = K sin(ωτ)
first crossing: ωτ = π/2, ω = K
therefore: Kτ = π/2
Below that first boundary the ideal linear loop is stable; at the boundary it loses that margin. The narrow-zone setting gives Kτ = 7.5 × 0.25 = 1.875, larger than π/2 ≈ 1.571. The original ±50 px setting gives 0.75.
This is an explanation to test, not an exact stability proof for the plotted simulation. The simulation has a deadband, saturation, sampled observations and noise, which the linear equation omits. A real person can anticipate, change speed and learn. Still, the calculation identifies a specific intervention: reduce gain independently of the required precision, rather than treating a smaller zone as permission to respond harder.
With a delayed binary display, the model can cross the target before the reversal arrives. Proportional feedback reduces motion near the target, but excessive gain or delay can still make it hunt.
Taking the idea back to an Uno
The v2 code changes more than the LED brightness. The laptop side uses YOLOv8, retains the hold-still reference mechanism, and sends numerical errors rather than direction words. It is an implementation of the idea to evaluate, not evidence that the simulated success rate transfers to a physical rig.
On a classic ATmega328P Uno, the pin allocation matters:
- PWM exists on pins 3, 5, 6, 9, 10 and 11. v1 put white and blue on 12 and 13, so two of its four directions cannot express intermediate brightness.
tone()conflicts with PWM on pins 3 and 11. Green moves from 11 to 9. The buzzer moves to 3, where losing PWM is harmless because the buzzer does not need a dimming channel.
This is a constraint of that board and timer implementation, not a statement about every board sold under the Arduino name. A control idea that ignores which timer owns an output has not reached the hardware yet.
A protocol is part of the control loop
rig/main_v2.py defines “far” as one quarter of the frame width. It divides each pixel error by that distance, multiplies by 100, clips to ±100 and sends a newline-terminated command:
E 50 -25
For a 640 px-wide frame, this corresponds to an 80 px rightward error and a 40 px upward error. The same frame-width scale is used for both axes. The example is useful because the numbers can be checked at both ends of the serial connection; it is not just an illustration of what a message might look like.
The sketch lights only the indicator for the appropriate sign on each axis. Beyond its acceptance threshold it maps magnitude to PWM levels from 20 to 255, keeping a small visible floor rather than fading all the way to an imperceptible light. The buzzer sounds only when both errors are acceptable.
There is an important difference from the study. Firmware ZONE = 12 is 12 percent of “far,” nominally 3 percent of frame width: about 19.2 px at 640 px width, before integer quantization. It is not the original ±50 px zone. Its brightness ramp also differs from the model’s 4b ramp. The plotted 2.0 percent failure rate therefore cannot honestly be presented as a measured result for this firmware.
When the camera stops seeing
No bottle means no fresh error message. Without a freshness rule, a disconnected camera or a lost detection could leave a perfectly bright instruction pointing toward an old target.
The sketch tracks the last parsed message and asks the outputs to go dark after 400 ms without an update. That is a useful change in meaning: darkness says “I do not have a current instruction,” rather than silently pretending the last one remains true.
It is not a hard 400 ms deadline. The loop uses blocking Serial.readStringUntil('\n'); an incomplete serial line can delay the watchdog check until that read times out. The distinction between a configured timeout and a guaranteed response time is exactly the kind of detail a working demonstration hides.
The reference-acquisition rule has limits too. In v2, “still” means successive detected centres move by less than eight pixels for three seconds. Slow accumulated drift can satisfy that condition; it is not a pose tracker. The detector takes the first returned bottle box rather than maintaining a target identity across multiple bottles. Those are concrete boundaries of the present implementation, not problems a nicer LED animation solves.
The bug I kept
The 2024 main.py has an operator-precedence bug: it sends leftdown instead of left,down. It works anyway because the Arduino checks whether each direction word appears in the line, not whether it received the intended comma-separated format.
That is why an end-to-end demonstration can pass while the interface contract is wrong. The producer and consumer accidentally tolerate each other. Replace either side with a parser that enforces the intended format and the same diagonal instruction can fail.
The original stays in the repository, bug included. The v2 protocol has explicit numerical fields; the tests retain the old behaviour on record. Keeping the historical version separate makes the change legible without rewriting what the 2024 project actually was.
Two bugs cancelling out is still two bugs.
What followed the lights
This belongs beside the 2024 bottle tracker, not above it as a more impressive project. Both started as camera demonstrations. One narrated motion with suspicious precision; the other reduced it to four lights. Both forced the later question: how old is the observation by the time somebody acts on it?
Underwater gate centring makes that question less forgiving. A detector updates, an observation waits, a controller asks for thrust, and a vehicle continues moving while the request takes effect. A person can quietly compensate for a bad display. A vehicle needs that compensation in its model, controller and stopping behaviour.
The connection is a way of thinking, not a claim that an Arduino desk rig validates an AUV. The later frame-age measurements ask what the camera pipeline actually delivers; Mongla keeps bench results separate from water trials. Four LEDs is an earlier point on that same thread.
Read, change, check
For the experiment, start with display(), trial() and score(), not the plot alone. Change delay, motion speed and the proportional ramp separately. Check failure rate and conditional settling time, then repeat with other seeds. A policy that looks faster only because almost every difficult trial failed is not an improvement.
For the hardware boundary, compare error_line() with level(), show() and the watchdog. Track units all the way from pixels through normalized percentages to PWM duty. Before interpreting a physical trial, make its acceptance zone and ramp match the model you intend to test.
For the theory, Åström and Murray’s freely available Feedback Systems provides the feedback, stability and frequency-domain foundations behind the delayed-loop argument. Arduino’s tone() reference documents the PWM conflict. The useful next reading is the one that explains a constraint in this rig, not a longer list of vaguely related robotics links.