From Prompt to Plant is the series where we share, openly and in full, the prompts that let you program an Industrial Shields PLC with Claude Code. The AI writes the code; you validate it on a test bench.
One signal. Many meanings.
A digital input on a PLC does not mean one single thing. It means whatever you know how to read. The same pulse can be a produced part, the start of a cycle, a machine running or stopped, a reject, a micro-stop nobody logs, or the real speed of the line.
Here is the interesting part: knowing what that signal means in your plant — and saying it right in a prompt — is worth as much today as knowing how to program it. Or rather: today it can replace it. The AI writes the firmware in minutes. What it cannot decide for you is what you measure and what it means. That interpretation — 24V, edge, debounce, what counts and what is noise — is the real engineering, and it goes inside the prompt.
The example
On a monitoring deployment on circular knitting machines, the usual problem: nobody knew how much each machine produced until someone counted pieces by hand at the end of the shift. The solution is one of the simplest there is: a 24V proximity sensor pointed at a moving part plus an ESP32 PLC. Each pulse, one unit. The "hello world" of the factory — and almost nobody has it set up.
The prompt (copy it in full)
Paste it as-is into Claude Code. If your model is another member of the ESP32 PLC family, change it in the first line: the I/O mapping changes between models.
Program an Industrial Shields ESP32 PLC 14 as a production counter (if your model is another member of the family, say so: the I/O mapping changes). 24V proximity sensor on I0_0, one pulse per cycle. Tell me which board to select in Arduino IDE. Count via a hardware INTERRUPT on the falling edge, not by polling (polling loses pulses when the firmware is writing to SD or reconnecting WiFi). Minimal ISR: just one volatile counter, no Serial or String inside. 30 ms software debounce inside the ISR. Two counters from the same interrupt: one for the interval (reset on send) and one for the shift (accumulates until reset). Every 20 s, an atomic read with noInterrupts()/interrupts(), an RPM estimate by extrapolating the interval to one minute, and publish over MQTT (or serial for the first test). Before the code, explain the sensor wiring and how to validate on the bench with manual pulses before installing on the machine.
What you get
Production per interval, shift total and live RPM, with machine-stop detection for free. Claude Code delivers the firmware with the debounced ISR, the two counters and the periodic report, plus an explanation of the sensor wiring and a bench-validation protocol.
Before the machine
House rule: the AI writes the code, the technician validates it. Validate on the bench first, generating pulses by hand or with a button, before going near the machine. And the technician is the one who decides what the signal means — that is the part that does not fit in a weekend.
Answer five questions about your project — your I/O, your protocol, your control logic — and get the full prompt sequence, built with the same methodology as this series. Free.
Open the PLC Prompt Generator →Every week, one real, verified prompt. Next episode: no Arduino IDE — Claude Code compiles and flashes your PLC on its own. Full archive and upcoming episodes on this blog, and in the From Prompt to Plant newsletter.