ChatGPT and Arduino code: what a chat window cannot see
Beginner
Or see every lesson.
- 505parts on the bench
- 45boards running now
- 1.00xreal time, on every board
Yes, ChatGPT and the other general chatbots can write Arduino code, and often good code. What they cannot do from a chat window is see your circuit, know which library version you have installed, or build the sketch to check it. You paste the code in, copy the answer out, and find out in the Arduino IDE whether it compiles and on the bench whether it works.
Mokxi AI, the helper in the Mokxi editor, is built the other way around: it starts from the project open in front of you and ends with a build. The circuit above is a button and an LED on an Uno, the sort of project to try it on.
Below is how to get good Arduino code out of any chatbot, what changes when the AI lives in the editor, and where each is the better tool.
Getting good Arduino code from any chatbot
Say which board: an Uno, an ESP32 and a Pico have different pins, different cores and different libraries, and an answer for the wrong one may not build at all. Say which pins things are on, and which library you use for each part, by name. Paste the whole sketch and the whole error message, not a summary of them.
Then check the answer. Build it before you trust it, read the lines that changed, and test it on the circuit. Most bad answers show themselves at the build: a function the library spells differently, a header that does not exist, a pin number the board does not have.
What a chat window cannot see
Your wiring. A chatbot knows the circuit only as well as you describe it, and the bug is often in the part you did not think to mention: the LED in backwards, the button on the wrong pin, a missing pull-up.
Your build. It cannot run your compiler, so it cannot know whether its answer builds with your board’s core and your library versions. You are the one who finds out, after copying it across.
An AI inside the editor
Mokxi AI gets the project itself with each question: every tab of code, the board, the parts and how they are wired, and the last build’s errors. Ask "Is my wiring right?" and it reads the wires, not your description of them. Ask "Why won’t this compile?" and it reads the error and the line.
Its fixes are compiled before you see the Accept button. Mokxi applies Mokxi AI’s edits to a copy of your file, builds it in your browser with the same compiler Run uses, and offers Accept only when it builds. And the simulator is right there: accept, press Run, and see whether the LED lights.
"What is sent" in the panel shows exactly what went with the last question. Nothing about you is sent, and Mokxi keeps none of the chat.
Where each is the better tool
A general chatbot is good for questions that are not about the project in front of you: comparing two sensors before buying, an idea for a project, the theory behind a circuit. It is also where you already are if you are working in the Arduino IDE on a real board.
Mokxi AI is better for the project open in Mokxi: a build error, a circuit that does not do what the code says, a sketch to start from for the parts on the canvas. It answers for that board, it can see the wiring, and its fixes build.
Either way, the simulator is the check that matters. Code that builds can still drive the wrong pin, and running it is how you find out before any hardware is involved.
A worked example
Take the button and LED above and break it: change INPUT_PULLUP to INPUT_PULLUPP and press Run. The build stops on that line. Asked in a chat window, the question needs the sketch, the error and the board pasted in, and the answer comes back as a whole new sketch to copy over yours.
In the editor, press "Why won’t this compile?" and Mokxi AI already has all three, so its answer can go straight to the line and the misspelled constant. Press Fix it and the card shows the lines it would change; once the copy builds it says "Compiles" and waits for Accept. Press Run and hold the button: the LED lights. The whole loop, from the error to a working circuit, happens without leaving the page, and nothing is copied anywhere.
The same goes for the questions with no error at all. "Why does my LED stay on?" is a question about the circuit as much as the code, and an answer that can read both gets to the cause sooner: a button wired to the wrong pin shows up in the wires, not in the sketch.
What it costs to try
Mokxi AI has questions every day for every signed-in account: 5 on a free account, 50 on the Pro trial and 100 on the paid plans. Mokxi itself, the editor and the simulator, is free.
Open this circuit in the editor. Arduino Uno: a button and an LED, to try an AI on, wired as it runs at the top of this page. Change a part or a value and run it again.
Open the circuitQuestions
Can ChatGPT write Arduino code?
Yes, and often well. Tell it the board, the pins and the libraries, paste the whole sketch and error, and build and test what it gives you before trusting it.
Why does ChatGPT’s Arduino code not compile?
Usually because it wrote for a different board, library or library version than yours: a function spelled differently, a header you do not have. It cannot build your sketch to find out.
Is there an AI that can see my Arduino circuit?
Mokxi AI in the Mokxi editor reads the circuit on the canvas, the parts and the wires, as well as the code, with each question.
Which AI is best for Arduino code?
The one that can check its answer. In Mokxi, Mokxi AI’s fixes are compiled before you can accept them, and the simulator shows whether they work.
Keep going
Where the facts on this page come from
Build this for real
Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.