Skip to main content

Arduino Mega 2560 Simulation

The Arduino Mega 2560 is powered by the ATmega2560 chip, which has 256KB of Flash program memory, 8KB of SRAM, and 4KB of EEPROM. The board features 54 digital pins, 16 analog input pins, and 4 serial ports. It runs at 16 MHz.


Getting Started

Place an Arduino Mega 2560 on the canvas and open the code editor by clicking on the Code tab. The Mega is code-compatible with the Uno — most Arduino sketches work without modification.

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}

Pin Layout

Pins 0–53 are digital GPIO pins. Pins A0–A15 double as analog input pins in addition to being digital GPIO pins.

Digital pins 2–13, 44, 45, and 46 have hardware PWM support (15 PWM channels total).

Power Pins

The simulator exposes the following power pins:

PinVoltage
5V5V
3.3V3.3V
GND0V
Vin9V
IOREF5V

Special Pin Functions

PinFunctionSignal
0Serial (USART0)RX
1Serial (USART0)TX
2External interruptINT4
3External interruptINT5
14Serial3TX
15Serial3RX
16Serial2TX
17Serial2RX
18Serial1TX
19Serial1RX
20I2CSDA (Data)
21I2CSCL (Clock)
50SPIMISO
51SPIMOSI
52SPISCK (Clock)
53SPISS (Chip select)

On-Board LED

The built-in LED on digital pin 13 is simulated. Use LED_BUILTIN to control it:

pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);

Simulation Features

FeatureStatusNotes
Processor (ATmega2560)✔️
GPIO✔️Including external and pin change interrupts
8-bit Timers✔️Timer0, Timer2
16-bit Timers✔️Timer1, Timer3, Timer4, Timer5. Input capture not supported
PWM✔️Pins 2–13, 44, 45, 46 — used by analogWrite(), Servo, tone
ADC✔️analogRead() on pins A0–A15 (16 channels)
USART✔️4 serial ports — Serial, Serial1, Serial2, Serial3
SPI🟡Master mode only
I2C🟡Master mode only
EEPROM✔️
Watchdog Timer✔️
Analog ComparatorNot yet supported

Legend:

  • ✔️ Supported
  • 🟡 Partial support
  • ❌ Not yet supported

Simulation Speed

The Arduino Mega 2560 runs at a 16 MHz clock frequency, matching real hardware.


Practical Limitations

  • SPI and I2C are master mode only — slave mode is not supported
  • No analog comparator — if your project uses the analog comparator, it cannot be simulated at this time
  • Timing may differ slightly from real hardware — most Arduino code is unaffected