Board

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.

Start building free
  • 8peripheral areas modeled
  • 4projects ready to run
  • Real timeon your own machine
Arduino Leonardo: blinklive0.000 s 0.00x
Click to open it in the editor
The board is running real firmware right now. Click it to open the circuit in the editor.
The model

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.
Start here

Open one and press Run

Each of these opens in the editor exactly as it is drawn here.

Projects

Every built-in project on the Leonardo

Each has its own page with the circuit running, the code and a parts list.

Libraries

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.

Servo.h
attach, write, writeMicroseconds, read, detach, on any pin
Wire.h
I2C as a master; Wire.begin() puts it on 2 (SDA) and 3 (SCL)
SPI.h
transfer and transactions, on the board’s usual SPI pins
EEPROM.h
read, write, update, get, put and EEPROM[i], kept in the chip’s own 1 KB EEPROM
LiquidCrystal_I2C.h
the 16x2 LCD behind its I2C backpack
Adafruit_GFX.h and Adafruit_SSD1306.h
the 128x64 I2C OLED: text, pixels, lines, rectangles, circles, triangles and bitmaps
Adafruit_NeoPixel.h
WS2812 strips and panels
DHT.h
the DHT11 and DHT22: temperature, humidity and the heat index, as floats you can print

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.

Learn

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.

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.