← All questionsClaude Code keeps writing delay() everywhere in my ESP32 sketch — how do I make it stop for good?
About Claude Code, ESP32 and Arduino
Every time I ask for a new feature it comes back with delay(1000) in the loop and the Telegram posting blocks everything. I keep saying 'use millis()' in the prompt and it forgets by the next session.
Replies
Put it in the CLAUDE.md in the project folder. Something like 'never use delay() in loop(), use millis() timers, here is the pattern' with a ten line example under it. It reads that file every session so you stop repeating yourself.
Sep 6Nico P., oakes, Mei-Lin and others agree
Small pushback: delay() is fine in setup() and for a sensor warmup. I'd say 'not in loop()' rather than 'never' or it starts doing weird non-blocking waits where a plain delay(50) was the right call.
Sep 7Mei-Lin and Pete H. agree
+1 to CLAUDE.md. I also keep a patterns folder with the two or three snippets I want copied exactly and point at them from the file. It's much more obedient when there's a file to copy than a sentence to interpret.
Sep 8quill and Pete H. agree
Also ask it to write the millis pattern as one tiny helper (every(ms) or whatever) and it'll reuse that instead of inventing a new timer each time.
Sep 7Mei-Lin agrees
Sign in to reply.
Replies sit in the order people agree with them; the ones the asker marks “helped” lead. Names, never a number.