Help someone fix their code

Answer a "why doesn't my code work" post on Reddit or the Arduino forum with the fixed sketch and a link that runs it, in under a minute.

Paste the code

Open mokxi.com/fix and paste the code from the post. No account is needed, and it works on a phone.

Mokxi guesses the board from the sketch (WiFi.h means an ESP32, A7 a Nano, and so on) and wires the parts the code talks to:

  • Libraries. Servo.h, DHT.h (DHT11 or DHT22), LiquidCrystal_I2C.h (16x2 or 20x4, at the address in the code), LiquidCrystal.h in 4-bit mode, Adafruit_SSD1306.h (128x64 or 128x32), Adafruit_NeoPixel.h and FastLED (with the LED count), NewPing.h, DallasTemperature.h (a DS18B20 with its 4.7k pullup), IRremote, and I2C sensors such as the BME280, MPU6050, DS3231 and BH1750.
  • Pins. Pin constants (#define LED 13, const int buttonPin = 2;, arrays of pins) and the pinMode, digitalWrite, digitalRead, analogRead, analogWrite, tone and attach calls on them. An output becomes an LED with a 220 ohm resistor, or a relay or buzzer when its name says so; an input becomes a button (to ground for INPUT_PULLUP, with a 10k pulldown for INPUT), or a PIR sensor when its name says so; analogRead becomes a potentiometer, or a light or temperature sensor by name. A trig and an echo pin become an HC-SR04.

A short note says what was wired, for example "We wired: servo on 9, LED on 13 (with 220 ohm)". Change the board from the Board list if the guess is wrong, and move or rewire anything in the editor. When the code says nothing about what is wired, the project opens on the board alone. LED_BUILTIN is the board's own LED, so nothing is added for it.

Run it and fix the errors

Press Run it. The editor opens with the fix bar over the canvas and runs the sketch. If it does not compile, the build panel lists each error with what it means in plain words, a one-tap fix where there is one, and Show me how, which walks through that error with a broken sketch and its fix. Edit the code and press Run again until it works.

Copy the answer

Press Copy answer on the fix bar. It copies a Markdown reply that pastes straight into Reddit or the Arduino forum:

  • one line on what was wrong (type your own, or keep the one Mokxi suggests from the first error it saw),
  • the fixed code in a code block,
  • the wiring Mokxi used, and
  • the link that opens the circuit running, with the words "Run it live in your browser (free, no account)".

The link carries the whole circuit inside it, so it opens for anyone, with no account. If the browser will not copy, open See the answer and copy it from there.

Say that you help build Mokxi

Reddit's self-promotion rules and the Arduino forum both ask anyone who links their own tool to say so. The answer ends with "I help build Mokxi.", on by default. Leave it on if you work on Mokxi; switch it off on the fix bar if you are simply a helper who likes the tool.