DEV Community

Hedy
Hedy

Posted on

How to simulate Arduino in Proteus?

Here’s a fast, reliable workflow to simulate Arduino projects in Proteus—from blink to UART/I²C.

1) Prerequisites

  • Proteus (VSM edition with Arduino models, e.g., ARDUINO UNO R3, ARDUINO MEGA 2560).
  • Arduino IDE 2.x (or Arduino CLI) to compile your sketch into a .hex.
  • Optional: VS Code/PlatformIO (works too—just grab the compiled .hex).

2) Get the HEX file from Arduino IDE

  1. Open your sketch.
  2. Sketch → Export compiled Binary (IDE 2.x puts the .hex in your sketch folder).
  • You’ll see: YourSketch.ino.hex (use this one; no bootloader needed).
  • Tip ( CLI ): arduino-cli compile --fqbn arduino:avr:uno --export-binaries .

3) Build the Proteus schematic

  1. Place → search “Arduino UNO R3” (or your board) → drop it on the sheet.

  2. Double-click the Arduino → set:

  • Program File = your .hex
  • Clock Frequency = 16 MHz (Uno) / 16 MHz (Mega uses 16 MHz too)
  1. Wire your circuit:
  • LED test: use built-in D13 (already on the Uno) or add LED + 220Ω to any digital pin.
  • Inputs: Push Button to a digital pin with pull-up/pull-down.
  • Sensors/Modules: connect to 5V/GND, A0–A5 (analog), D0–D13 (digital), I²C (A4/SDA, A5/SCL on Uno).
  1. Virtual instruments (very handy):
  • Virtual Terminal (for Serial): place and wire to TX(D1)/RX(D0).
  • Oscilloscope/Logic Analyzer for PWM/I²C/SPI lines.
  • I²C Debugger to watch addresses/bytes.

4) Run it

Click Play ▶️ in Proteus. Watch LEDs toggle, read serial output, probe signals.

5) Minimal test sketches
A) Blink (uses on-board D13 LED—no wiring needed)

void setup() { pinMode(13, OUTPUT); }
void loop()  { digitalWrite(13, !digitalRead(13)); delay(500); }
Enter fullscreen mode Exit fullscreen mode

B) Serial + Analog read (use Virtual Terminal on D0/D1)

void setup() { Serial.begin(9600); }
void loop()  { int v = analogRead(A0); Serial.println(v); delay(200); }
Enter fullscreen mode Exit fullscreen mode

In Proteus, add a POT to A0 (wiper→A0, ends→5V/GND) and a Virtual Terminal to D0/D1.

C) I²C LCD (if your Proteus has one; otherwise use generic HD44780 in 4-bit mode)

#include <Wire.h>
#include <LiquidCrystal_I2C.h> // install in IDE
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(){ lcd.init(); lcd.backlight(); lcd.print("Hello, Proteus!"); }
void loop(){}
Enter fullscreen mode Exit fullscreen mode

Wire SDA=A4, SCL=A5, add the I²C LCD model, address 0x27 (or as provided).

6) Common pitfalls & fixes

  • Blank or “program stopped” → Wrong board/clock. Recompile for the exact board (e.g., Uno) and set 16 MHz in Proteus.
  • “Opcode not implemented” → Using features the Proteus MCU model doesn’t emulate (rare on AVR). Simplify or update Proteus.
  • No Serial output → Use Virtual Terminal on D0/D1, match baud (e.g., 9600). Close Arduino IDE’s Serial Monitor (it locks the port, though Proteus uses virtual wiring).
  • I²C not responding → Check pull-ups (some models include them; add 4.7 kΩ to 5V if needed). Confirm slave address.
  • Libraries → Proteus can’t “see” Arduino libraries; they’re compiled into the .hex. Install libs in Arduino IDE, re-compile, re-export .hex.

7) Tips for realistic sims

  • Use timers/PWM and watch on the oscilloscope (check duty/frequency).
  • Simulate sensors with V sources, POTs, or built-in models (LM35, LDR, etc.).
  • For UART-to-PC testing, use COMPIM (bridges to your real COM port).
  • Keep Proteus time step reasonable if you simulate fast serial or PWM (Simulation → Controls → Set Timestep).

8) Quick checklist

  • Export .hex for the exact board (Uno/Mega etc.)
  • Program file loaded, 16 MHz set
  • Power nets: 5V and GND to all peripherals
  • Virtual Terminal/Scopes connected and baud/frequency matched
  • Pull-ups/pull-downs where required

Top comments (0)