Arduino Leonardo simulator, with Serial on the USB
The Leonardo is the Arduino whose USB socket goes to the microcontroller. An ATmega32U4 at 16 MHz on an Uno's outline: the same shield headers, and a `Serial` that is a USB CDC endpoint rather than a UART, with `Serial1` on pins 0 and 1 as a port of its own.
- 8peripheral areas modeled
- 4projects ready to run
- Real timeon your own machine
What is modeled
Taken from the board's own contract document and put in plain words, with what is missing beside it.
Modeled
- Core
- Every ATmega32U4 mnemonic with datasheet cycle counts, at 16 MHz
- Ports
- B to F, with the 44-pin package’s gaps: port C is PC6 and PC7, port F has no PF2 or PF3
- Timers
- Timer 0, timers 1 and 3, and timer 4 (the ten-bit one, with TOP in a register and channels A, B and D)
- PWM
- Seven pins: 3, 5, 6, 9, 10, 11 and 13, at 976.5625 Hz or 490.196 Hz depending on the timer
- USB
- A byte pipe at the real endpoint registers: enough for a CDC serial port, and nothing above it
- USART1
- Real 8N1 frames on pins 0 and 1, one bit at a time, so a jumper between them carries a character
- ADC
- Fourteen channels, MUX5 in ADCSRB bit 5, and A6 to A11 that are also digital pins
- Interrupts
- INT0 to INT3 and INT6, one pin-change group on port B, and sleep
Not modeled
- The USB stack above the byte pipe: no enumeration, no descriptors, no SETUP. `while (!Serial)` returns at once here and waits on a desk.
- Keyboard and Mouse. They are the other half of what a 32U4 is for, and they need the stack that is not there.
- SPI, TWI, the analog comparator, and the PLL that would clock timer 4 faster than 16 MHz.
- The Leonardo ETH. The Micro and the Pro Micro are the same chip on other pinouts, and have pages of their own.
Open one and press Run
Each of these opens in the editor exactly as it is drawn here.
Every built-in project on the Leonardo
Each has its own page with the circuit running, the code and a parts list.
Arduino libraries that compile as they are
Paste a tutorial that includes one of these and it builds. For any other library, the build names the Mokxi header that does the same job.
And 17 more, 25 in all: OneWire.h and DallasTemperature.h; Adafruit_BME280.h, Adafruit_BMP280.h and SparkFunBME280.h; RTClib.h; Adafruit_SHT31.h; Adafruit_PCF8591.h; Adafruit_ADXL345_U.h; LedControl.h; Adafruit_LEDBackpack.h; Adafruit_TCS34725.h; Adafruit_SGP30.h; Adafruit_INA219.h; Adafruit_ADS1X15.h; Adafruit_MCP23X17.h; Bounce2.h; Keyboard.h and Mouse.h; Joystick.h; HX711.h.
Tutorials that use this board
Each one ends in a running circuit, on this same board.
Questions
Is it free?
Yes. Every board and every part is on the free plan, with no account needed.
Why is Serial different from an Uno’s?
Because the hardware is. On an Uno a separate chip turns USB into a UART, so Serial is USART0. On a Leonardo the USB goes to the ATmega32U4 itself, so Serial is a CDC endpoint and Serial1 is the UART on pins 0 and 1.
Can I make it act as a keyboard?
Not here. Keyboard and Mouse need the USB stack above the byte pipe, and the model says plainly that it does not have one.
Will an Uno sketch run on it?
The source usually will. The ELF will not: it is a different chip with a different register map. And SDA and SCL are pins 2 and 3 here, not A4 and A5.
The other boards
Every one of these runs today, and every one is free.
Looking for the shorter introduction? See the Arduino Leonardo simulator page.
Every Arduino board in one place: the Arduino simulator.
A RISC-V chip at 160 MHz, on the real memory map.
The classic Arduino, with an ATmega328P running at 16 MHz.
The Uno’s chip on a small board that fits a breadboard.
The big Arduino, with 54 digital pins and four serial ports.
A second RISC-V board, with 31 pins and simulated WiFi.
The classic ESP32 at 240 MHz, with simulated WiFi.
The ESP32-S3 at 240 MHz, with USB serial and an RGB LED.
The NodeMCU’s ESP8266 at 80 MHz, with simulated WiFi.
Try it on your own firmware
What you build here runs on the board on your desk, unchanged. Nothing to install and no account needed.