Another Arduino emulator with its web interface for testing your .ino files without physical hardware or complex simulator. This tool allows you to test your Arduino code directly from your PC without any hardware setup, featuring an immediate human-machine interface to emulate GPIOs, communication. No complex wiring or physical setup required - just write your code and interact with virtual pins through a simple, direct web interface.
Note: Default board is Arduino Uno (20 pins: D0-D13, A0-A5). Custom board configurations can be loaded via JSON files (see Board Configuration)
Screenshot of the web interface launched from a Linux console (appearance may change as the project evolves)
- Instant Feedback: See results immediately on your web browser without uploading to physical boards.
- Cost-Effective: Develop and test without investing in multiple Arduino boards or components.
- Educational Tool: Perfect for learning Arduino programming without hardware constraints.
- Simplified Testing: No need for complex wiring or breadboard setups. You can use GDB directly.
- Intuitive HMI: Easy-to-use interface for interacting with virtual pins configured from your ino code.
- Web Browser Interface: Access the complete emulation environment directly in your web browser.
- Direct Interaction: Toggle GPIOs, adjust analog values, and monitor outputs with simple clicks.
- No Complex Setup: Skip complicated wiring and component connections.
- Arduino Lifecycle: emulates the Arduino execution by calling
setup()once at initialization, then repeatedly executingloop()at configurable frequency. - Detection of infinite loops: after 5 seconds of inactivity from the
loop()a watchdog halts and restore the simulation. - Digital I/O: Complete
digitalWrite(),digitalRead()support. - Analog I/O: Full
analogWrite()(PWM) andanalogRead()(ADC 10-bit) emulation. - Pin Modes: INPUT, OUTPUT, INPUT_PULLUP, INPUT_PULLDOWN, OUTPUT_OPEN_DRAIN with
pinMode(). - PWM Pins: 6 PWM-capable pins (D3, D5, D6, D9, D10, D11).
- Analog Pins: 6 analog input pins (A0-A5) with 0-1023 range.
- millis() and micros(): Real-time clock emulation.
- delay() and delayMicroseconds(): Accurate timing.
- Timer callbacks: Periodic interrupt simulation.
- tone(): Generate square wave tones at specified frequencies using SFML audio output.
- noTone(): Stop tone generation.
- Real Audio Output: Actual sound generation through system audio (requires SFML audio library).
- Frequency Control: Supports the full range of audible frequencies.
- Serial: Complete UART bus emulation: Serial.print(), Serial.read(), ... support.
- SPI: Complete SPI bus emulation (begin, transfer, end). HMI coming soon
- I2C: Arduino and HMI Coming soon.
- Default Board: Arduino Uno (20 pins: D0-D13, A0-A5)
- Custom Boards: Load custom board configurations via JSON files (see Board Configuration)
- Configurable: Pin count, PWM pins, analog pins, and pin mapping
- π No I2C emulation (coming soon)
- πΎ No EEPROM support (coming soon)
- β±οΈ Timer uses system real time (not cycle-accurate)
Compile the whole project as described in the next section.
Prerequisites:
- C++17 compiler (g++ or clang++)
- SFML 2.5+ (for audio support)
On Debian/Ubuntu, install SFML:
sudo apt-get install libsfml-devFrom your Linux console, type the following lines:
git clone git@github.com:Lecrapouille/ArduinoEmulator.git --recurse-submodules
make download-external-libs
make -j8Modify the src/arduino_user.cpp file to point to your .ino file:
#include "../doc/examples/example.ino" // Change this pathCompile again:
make -j8You have several examples given in this repo to test.
From your Linux console, launch the emulator:
./build/Arduino-Emulator [OPTIONS]A message like this one, shall appear:
========================================
Arduino Emulator Web Interface
Board: Arduino Uno
Server address: 0.0.0.0
Server port: 8080
Arduino loop rate: 100 Hz (10 ms)
Web client poll rate: 200 Hz (5 ms)
========================================
Starting server...
Server started successfully!
Open your browser at: http://localhost:8080
Press Ctrl+C to stop the server
========================================Command Line Options:
- -a, --address arg Server address (default: 0.0.0.0)
- -p, --port arg Server port (default: 8080)
- -f, --frequency arg Arduino loop rate in Hz (1-100, default: 100)
- -b, --board arg Board configuration JSON file
The -f option controls the Arduino loop() execution rate (max frequency). The web client will poll at 2x this frequency to capture all state changes. Lower frequencies reduce CPU usage but increase latency.
The -b option: Board configurations are given in this boards folder.
VSCode
Alternatively, people with VSCode or Cursor IDE, can directly launch the debugger and run step by step the code. You can modify the launch file.
Open your browser at http://localhost:8080
The interface allows you to:
- Start/Stop/Reset the simulation.
- View pin states (mode, value, PWM).
- Simulate inputs by changing pin values (digital, analog).
- Serial Monitor to see program output.
- Send data to Serial, I2C, SPI.
The web interface provides multiple interactive panels to display the Arduino Uno states and interact with it. Let describe each panel.
The Arduino emulator starts in a stopped state. You need to:
- Start: Click to begin the simulation (runs
setup()thenloop()continuously) - Stop: Pause the simulation (freezes the current state)
- Reset: Stop and reset all pin states to their initial values, then restart if it was running
Displays the state of all pins (D0-D13, A0-A5) with:
- Visual indicators for HIGH/LOW states
- Pin mode badges (INPUT, OUTPUT, INPUT_PULLUP, INPUT_PULLDOWN, OUTPUT_OPEN_DRAIN)
- Real-time LED indicators for digital pins
Pedagogical Note: For educational purposes, pins are only displayed and enabled in the interface if
pinMode()has been explicitly called in your Arduino code. This teaches the importance of proper pin initialization, even for INPUT pins.
The LED indicators (D0-D13) provide visual feedback:
- OFF: Pin is LOW (0V)
- ON: Pin is HIGH (5V)
- Variable brightness: For PWM pins, the LED brightness varies proportionally to the PWM duty cycle (0-255)
Interactive toggles to simulate digital inputs:
- Emulate button presses and sensor readings.
- Only enabled for pins configured as INPUT with the
pinMode()function. - Disabled for OUTPUT pins or controlled by Arduino code (i.e. serial ...)
Sliders for PWM-capable pins (D3, D5, D6, D9, D10, D11):
- Real-time PWM value display (0-255).
- Visual feedback on LED indicators.
- Monitor
analogWrite()output. - Read-only: Sliders are controlled by Arduino code and cannot be modified by the user.
Sliders to simulate analog sensor readings (A0-A5):
- Range: 0-1023 (10-bit ADC).
- Real-time voltage display.
- Only enabled for pins used with
analogRead().
Serial communication terminal:
- View all
Serial.print()andSerial.println()output. - Send data to the Arduino (simulates Serial input).
- Timestamped messages.
- Clear button to reset the terminal.
Messages and debugging information from the emulator itself:
- Simulation status changes.
- GPIO toggle events.
- Analog input changes.
- Error messages.
All endpoints are accessible via HTTP:
POST /api/start- Start the simulationPOST /api/stop- Stop the simulationPOST /api/reset- Reset the simulation
Note: POST requests must include Content-Length: 0 if they have no body.
-
GET /api/board- Get board configurationResponse:
{ "name": "Arduino xxx", "pwm_pins": [ 3 ], "pin_mapping": { "A0": 14 }, "analog_only_pins": [ 20 ] } -
GET /api/tick- Get Arduino loop tick counter (lightweight state change detection).Response:
{"tick": 12345}This counter increments after each
loop()execution. The web client uses it to detect when to fetch full pin states, avoiding unnecessary polling.
-
GET /api/pins- Get the state of all pins (0-19)Response:
{ "pins": { "0": {"value": 0, "mode": 0, "pwm_capable": false, "pwm_value": 0, "configured": true}, ... } } -
POST /api/pin/set- Set a digital pin value (simulate input)Request:
{"pin": 2, "value": 1} -
POST /api/pwm/set- Set a PWM value for PWM-capable pinsRequest:
{"pin": 3, "value": 128} -
POST /api/analog/set- Set an analog pin value (simulate analog sensor)Request:
{"pin": 0, "value": 512}Note:
pinis the analog pin number (0-5 for A0-A5), not the physical pin number.
-
GET /api/serial/output- Read Serial output (consumes the buffer)Response:
{"output": "LED: ON\n"} -
POST /api/serial/input- Send data to SerialRequest:
{"data": "test"}
- C++17
- MyMakefile - Makefile macros
- cpp-httplib - HTTP server
- nlohmann/json - JSON parser
- cxxopts - CLI parser
- SFML - Simple and Fast Multimedia Library
Dependencies are included in the external/ folder. MyMakefile shall be included when git cloning recursively this project. Other third-parties are downloaded by MyMakefile with the command make download-external-libs. They are not installed on the operating system.








