Categories
Technical Projects Working with AI

The First Idea Is Usually the Worst Idea

I prefer solving a problem after understanding and evaluating what is working/not working and why. Consistently it looks like Claude (and most AI) tends to pick a direction based on the first “thought” it has and does not consider re-looking for simpler solutions.

This is a field note from an afternoon spent arm wrestling with Claude. I was working on my LyteSync product. I prefer solving a problem after understanding and evaluating what is working/not working and why. Consistently it looks like Claude (and most AI) tends to pick a direction based on the first “thought” it has and does not consider re-looking for simpler solutions.

I asked Claude to write up what happened, wrong turns included, and it did so from its own side of the bench: where the note says “I”, that is the AI, and “the person holding the hardware” is me. I am posting it because the pattern is bigger than this one bug. The first explanation that fits is cheap to act on, and in firmware it will often make the symptom vanish while leaving the cause exactly where it was.


LyteSync · LYT96 · Field note · Nov 3, 2026

The problem we worked on; if I started the device from a battery it would not send any RF data, if I started it plugged in to USB on the Mac, it would.

An afternoon on a custom radio that would not start produced one fix worth three lines and nine wrong turns worth writing down. Every wrong turn had the same shape: a hypothesis that fit the evidence, was cheap to act on, and made the symptom disappear without touching the cause. Firmware is unusually generous to bad first ideas, because the boot sequence is short, the instruments are scarce, and almost anything you insert into it appears to work.

1. The symptom, and the three lines underneath it

A battery-powered remote broadcasts a show clock over the nRF52840’s on-die radio; any number of controllers receive it and play the same colour sequence in lockstep. On cold power from the barrel jack, with the start switch already on, the remote would sometimes never transmit. The light strip simply stayed dark. No error, no serial output, nothing to read.

The code that decided this was in the tree for months and reads like a hardware check:

radio.begin();
if (radio.isChipConnected()) {
// ok
} else {
while (1)
;
}

Here is what is actually happening, which took most of a day to establish. nrf_to_nrf::begin() starts the high-frequency crystal oscillator, then the low-frequency clock, waiting up to 250 ms for each. On either timeout it returns false early, before it ever reaches NRF_RADIO->POWER = 1 and the register setup that follows. The return value is a bool, and the code above throws it away.

Then isChipConnected() is asked whether the radio is present. It is isValid(), and all it does is write NRF_RADIO->FREQUENCY and read it back. On a radio that was never powered, that read-back cannot succeed. So the check answers truthfully and reports the wrong thing: not “the clock was slow”, but “there is no radio here”.

Conclusion. A transient clock-start failure was converted into a permanent halt, and the halt was silent. The defect was three lines long. Nothing about the symptom pointed anywhere near it.

2. First idea: the radio needs time to settle

The idea: The radio is coming up before its hardware is ready. Give it a moment: delay(2000) at the top of setup().

What was true: Crystal start-up on this part is specified in fractions of a millisecond. Two seconds was roughly four orders of magnitude more than the requirement, and it was the bulk of a measured eight-second boot.

The delay worked, in the only sense that mattered to it: the fault stopped reproducing. It was wrong in four independent ways, and it is worth separating them, because only the first is the one people notice.

  • It was far too long. Nobody had measured what the wait needed to be, so the number came from the same place the theory did.
  • It cost the user eight seconds of boot. On a device whose entire job is to start a synchronised show when someone holds a switch, that is the headline feature degraded to fix an invisible bug.
  • It destroyed the evidence. The fault was intermittent. A change that stops an intermittent fault from appearing also stops you from ever finding it.
  • It was never compared against the alternative. No build without it was tested on the same hardware in the same conditions.

Conclusion. A fixed delay is a bet on a worst case you have not measured, and it pays for itself by deleting the data you would need to settle the bet.

3. A fix that works is not evidence

The delay appeared to confirm the theory, because after it went in the remote started reliably. But the runs that seemed to prove it were confounded, and by something embarrassingly physical: the start switch is a slide switch, and its position decides whether the remote transmits at all. It had been moving between runs. Two variables, one observation, and a conclusion drawn anyway.

This is the weakest form of evidence available, and intermittent faults specialise in producing it. “It stopped happening” is also what the fault does on its own, several times an hour, for free.

Conclusion. Confirmation that a change removed a symptom is not confirmation of why. For an intermittent fault, a run of successes is indistinguishable from luck until you can state the mechanism and predict when it will fail.

4. The second mask was not a delay at all

Once the two-second delay was understood as wrong, it came out. The remote still worked. That looked like the end of the story, and it was not, because something else in setup() had quietly inherited the job: a 150 ms indicator blink, added for an entirely unrelated reason, so that the operator could see the board had powered up.

The blink was later dropped as a cosmetic simplification. The radio fault came back on the next cold boot. A change to an LED reintroduced a radio bug.

Conclusion. A delay that masks a race is indistinguishable from a feature. Removing one mask and seeing no fault does not prove the mask was unnecessary. It may only prove there is another one you have not recognised yet, because it does not look like a delay.

5. Diff the artifacts, not your beliefs about them

What finally settled it was not reasoning. Two build directories had been kept: the last image that worked, and the first that did not. Disassembling the setup() symbol in each and diffing the result took about a minute.

// last good
pinMode(13, OUTPUT)
digitalWrite(13, LOW) // indicator ON (active-low)
delay(150)
digitalWrite(13, HIGH) // indicator OFF
delay(0) // the settle delay, already zero
radio.begin()
// first bad
pinMode(13, OUTPUT)
digitalWrite(13, HIGH) // indicator OFF
radio.begin() // immediately

Both builds already had the settling delay at zero. The entire difference was the blink. Eight lines of assembly answered a question that hours of argument had not, and they answered it because the compiler does not share anyone’s conceptual categories. To me the blink was a user-interface detail and the delay was a timing fix; to the object code they were the same thing, and only one of them was still there.

This was only possible because every test build had gone to its own directory. One reused output path and the evidence would not have existed.

Conclusion. When two builds differ in behaviour, diff the builds. Your model of what changed is exactly the thing under suspicion, so it is the worst available source for what changed. Keep every test artifact; they cost nothing and they are the only record that is not a memory.

6. The schematic is not the hardware

The idea: The v3.1 schematic shows the start switch on D7, and nothing on D10. So the pin assignment in the firmware is wrong, and D7 is correct.

What was true: The board in hand has the switch on D10 with an external pull-down. The PDF describes a different revision of the board.

I extracted the PDF, read the net labels, found a clean answer, and changed the pin on the strength of it. The owner of the board corrected it in one sentence. The change was reverted, and the firmware now carries a comment saying the schematic disagrees and which one to trust.

The failure here is not that the document was out of date. Documents go out of date; that is their nature. It is that a document felt like ground truth because it was precise, internally consistent, and had a version number on it. Precision is not currency.

Conclusion. A schematic is a claim about hardware with a date attached. When the two disagree the hardware wins, and the disagreement is worth a comment in the source, because the next person will find the same PDF and it will be just as convincing.

7. A probe that depends on the subsystem under test is not a probe

Three instruments were built to measure the boot sequence, and all three were useless in a way that was only obvious afterwards.

  1. A one-shot print of the boot timings, emitted during setup(). The host had not attached to the USB CDC port yet, so the output went nowhere.
  2. A probe moved after the serial wait so the host would be listening. It then measured the serial wait, which was the one interval nobody was asking about.
  3. A report gated on a variable that was supposed to mark the first transmission, and which a HIGH pin set immediately. It reported instantly, every time, on a board that had not transmitted.

All three shared one root cause: they were built on the subsystem whose timing was in question. Instrumenting a boot race means instrumenting the interval before your instrument exists.

Conclusion. Before trusting a measurement of start-up, ask what the probe itself needs in order to work, and whether the thing being measured is upstream of it. If it is, the probe is a participant and not an observer.

8. A health check downstream of an unchecked init measures the init

This is the general form of the defect in section 1, and it is the item from this list most likely to be sitting in someone else’s code right now.

begin() returned a value describing exactly what went wrong. It was discarded. A different question was then asked, “is the chip there?”, and that question’s answer had already been decided by the call whose answer was thrown away. The probe could only be reached through the failed initialisation, so it was reporting on the initialisation while appearing to report on the hardware.

The shape is worth recognising on sight:

thing.begin(); // returns bool. ignored.
if (!thing.isPresent()) { // reads state begin() was supposed to set
halt(); // and now it is permanent
}

Conclusion. Check the value you were given before inventing a probe. A diagnostic whose result depends on an initialisation you did not check is not independent evidence, and when its failure branch is a halt, it converts every transient fault in that path into a dead device.

9. Making a failure survivable can expose a latent lie

The controller firmware has a deliberately small status vocabulary on its on-board LED: red while it is reading its show files, off once it is loaded and running normally, red forever if the load failed. The strip itself stays dark until showtime, so the audience never sees the board’s internal state.

That vocabulary had a hole in it. STATUS_OFF() ran before radio.begin(), so a board that was stuck on its radio displayed “loaded, running normally”. Under the old code this was unreachable in practice: the failure branch was a halt, so the window between claiming success and hanging was zero-width, and nobody ever saw it.

Converting the halt into a retry created duration where there had been none. The lie became reachable, and the fix was to move the one line so that red covers the whole of bring-up and off means genuinely ready.

Conclusion. A status indicator placed by position in the code rather than by a verified condition is a latent bug. Recovery logic is often what exposes it, because recovery is what turns an instant into an interval.

10. “It has worked for months” is not evidence the pattern is safe

All three sketches in this repository had the identical discarded begin(). Only the remote ever failed in the field. The reason is pure accident of scheduling, and it is the most useful thing in this paper.

SketchWhat happens before begin()Field behaviour
remoteAlmost nothing: one pinMode and one digitalWriteIntermittent dead boot on jack power
controllerdelay(2000), pin setupNever observed to fail
controller-nrfdelay(2000), PWM setup, status LED, flash mount and show-file parseNever observed to fail
Same three lines, three arrival times

The two controllers reach the defective code seconds after reset, by which time the crystal has long since started. The remote reached it microseconds after reset. Same defect, opposite behaviour, decided entirely by what happened to be scheduled in front of it.

Conclusion. For a race, the dangerous variable is when the call happens, not whether the code looks right. Audit siblings by timing, not by similarity, and treat a long clean history in one of them as evidence about its schedule, not about its correctness.

11. The fix, and why its shape matters

Three lines, and not a number in sight:

while( !radio.begin() || !radio.isChipConnected() ) {
delay(RADIO_RETRY_MS);
}

This is a better shape than any delay, for a reason that generalises: it is self-measuring. The cost tracks what the hardware actually needs on this boot, on this board, at this temperature. begin() is attempted before the first delay, so a warm board is ready immediately and pays nothing. No constant has to be correct for the code to be correct; RADIO_RETRY_MS only sets how finely the wait is quantised.

It also preserves the one good property the original had. A genuinely absent radio still never gets past this loop, and still says so the only way the hardware can: by never lighting the ready indicator. Dark means not ready, before and after.

MeasureBeforeAfter
Remote boot to first packet (jack power)~8 simmediate
controller-nrf flash99,652 B99,668 B
controller-nrf RAM179,508 B179,508 B
Fixed delays required1–20
What the fix cost

Conclusion. Prefer a fix whose cost is measured by the hardware over one whose cost is chosen by the author. Sixteen bytes of flash bought the removal of every magic number in the boot path.

12. The ledger

What the first ideas cost, written down so the total is visible in one place rather than spread across a day:

  • An afternoon, most of it spent confirming a theory rather than testing it.
  • A two-second delay briefly shipped in a device whose purpose is prompt response.
  • A cosmetic simplification that silently reintroduced a radio fault.
  • Three instruments built and discarded, each measuring itself.
  • One pin reassignment made on the authority of a PDF, and reverted by someone looking at the board.
  • One status indicator that would have claimed success on a hung board, found only as a side effect.

Against that, the two observations that actually moved things forward both came from the person holding the hardware: that a debug build booting faster than a release build makes no sense, and that a particular line was calling the wrong one of two similarly named functions. Neither required reading any source.

13. Limitations

Stated plainly, because the mechanism in section 1 is inferred rather than observed:

  • The clock-start explanation comes from the library source and from the asymmetry between USB-powered and jack-powered boots. Nobody has put a scope on the crystal, and nobody has yet read the retry counter the debug build now keeps. That counter on a cold board is the cheap confirmation and it has not been done.
  • Both controllers still carry delay(2000). They were deliberately left alone: removing them is a separate change from fixing the trap they were hiding, and a controller that boots late costs nothing here, because absolute cumulative timestamps let it join a show already in progress.
  • The Nano branch has the same retry but a different radio: an external module over SPI, where a failed begin() means something other than a slow crystal. The fix is correct there for different reasons, and the fault described here has never been seen on it.
  • One sample of hardware, one crystal, one room temperature. The intermittency rate was never quantified.

Companion paper: The Cable That Started the Clock, on why every available way of observing this fault also cured it.