Arduino Leonardo pinout: the Uno’s shape, a different chip
Beginner
Or see every lesson.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
The Leonardo has an Uno’s outline and an Uno’s headers, hole for hole, but an ATmega32U4 instead of an ATmega328P, and that moves things a sketch cares about. I2C is on pins 2 and 3, not A4 and A5. SPI is only on the ICSP header. Serial is the USB socket and Serial1 is pins 0 and 1. And six digital pins are analog inputs too. This page lists every pin with the chip pin behind it, then power, PWM, the interrupts, the buses and which pin to use for what.
The circuit above is a Leonardo in Mokxi fading two LEDs at once: one on pin 13, from the chip’s ten-bit timer 4, and one on pin 9, from an ordinary 16-bit timer. The table is read from the same board model the simulator runs, and where Mokxi does less than the board, the row says so.
Every pin, with its ATmega32U4 pin
The top header reads SCL, SDA, AREF, GND, then 13 down to 0; the bottom one reads IOREF, RESET, 3V3, 5V, two GNDs, VIN, then A0 to A5. The chip pin column is the port and bit, which is what the datasheet and a register-level sketch use. SCL and SDA beside AREF are not extra pins: they are wired to 3 and 2.
A0 to A5 are digital pins 18 to 23 as well. The last three rows are the six-pin ICSP header beside the chip: its MISO, SCK and MOSI pads are the board’s only SPI pins, and its other three pads are a second 5V, RESET and GND, the same metal as the power header’s.
| Pin | Chip pin | What it can do | Watch out for |
|---|---|---|---|
| SCL | PD0 | I2C SCL: the same pin as 3. | Not a separate pin: anything on 3 is on SCL. |
| SDA | PD1 | I2C SDA: the same pin as 2. | Not a separate pin: anything on 2 is on SDA. |
| AREF | - | The analog reference, for analogReference(EXTERNAL). | Not a GPIO. |
| GND | - | Ground. Three pins. | - |
| 13 | PC7 | PWM on timer 4, 976 Hz. The L LED, lit when HIGH. | Not SPI SCK as on an Uno: SPI is on ICSP. |
| 12 | PD6 | Digital. Also analog input A11. | Not SPI MISO as on an Uno: SPI is on ICSP. |
| 11 | PB7 | PWM. | Not SPI MOSI as on an Uno: SPI is on ICSP. |
| 10 | PB6 | PWM. Also analog input A10. | The Servo library takes timer 1, which drives 9 and 10. |
| 9 | PB5 | PWM on timer 1, 490 Hz. Also analog input A9. | The Servo library takes timer 1, which drives 9 and 10. |
| 8 | PB4 | Digital. Also analog input A8. | - |
| 7 | PE6 | Digital. INT6: attachInterrupt. | The one interrupt pin that is not Serial1 or I2C. |
| 6 | PD7 | PWM on timer 4. Also analog input A7. | - |
| 5 | PC6 | PWM. | - |
| 4 | PD4 | Digital. Also analog input A6. | - |
| 3 | PD0 | PWM. I2C SCL. INT0: attachInterrupt. | Used by any I2C device. |
| 2 | PD1 | Digital. I2C SDA. INT1: attachInterrupt. | Used by any I2C device. |
| 1 | PD3 | Serial1 TX. INT3: attachInterrupt. | Serial is the USB socket, not this pin. |
| 0 | PD2 | Serial1 RX. INT2: attachInterrupt. | Serial is the USB socket, not this pin. |
| IOREF | - | Tells a shield the board runs at 5 V. | Not a GPIO. |
| RESET | - | Reset: low restarts the chip, as the button does. | Not a GPIO. |
| 3V3 | - | 3.3 V from a small regulator. | Not a GPIO. A sensor, not a radio. |
| 5V | - | The 5 V rail, from USB or the regulator. | Not a GPIO. |
| VIN | - | Power in for the regulator, 7 to 12 V by Arduino’s spec. | Not a GPIO. Mokxi ignores it; the board is on USB. |
| A0 | PF7 | Analog in. Digital 18. | - |
| A1 | PF6 | Analog in. Digital 19. | - |
| A2 | PF5 | Analog in. Digital 20. | - |
| A3 | PF4 | Analog in. Digital 21. | - |
| A4 | PF1 | Analog in. Digital 22. | Not I2C, as it is on an Uno. |
| A5 | PF0 | Analog in. Digital 23. | Not I2C, as it is on an Uno. |
| MISO | PB3 | ICSP pin 1. SPI MISO. Digital 14. | Only on the ICSP header. |
| SCK | PB1 | ICSP pin 3. SPI SCK. Digital 15. | Only on the ICSP header. |
| MOSI | PB2 | ICSP pin 4. SPI MOSI. Digital 16. | Only on the ICSP header. |
Power pins and their limits
The Leonardo runs at 5 V from its micro-USB socket, or from 7 to 12 V on the barrel jack or VIN through its regulator. 5V is that rail, 3V3 is a small regulator for a sensor, and IOREF tells a shield the logic is 5 V. Arduino’s spec sheet gives 10 mA per I/O pin as the figure to design to; the ATmega32U4’s absolute maximum is 40 mA. In Mokxi the board is always on USB, VIN is ignored, and 5V is an ideal rail that cannot sag.
Serial is the USB, and Serial1 is pins 0 and 1
There is no USB-serial chip on a Leonardo: the ATmega32U4 talks USB itself, and Serial is that USB port. It reaches no pin. Serial1 is the chip’s UART on pin 1 (TX) and pin 0 (RX), for a GPS, a Bluetooth module or another board. On a real Leonardo while (!Serial) {} waits for the computer to open the port; in Mokxi it returns at once.
The board also has RX and TX lamps, on PB0 and PD5, which have no header pin. They are wired so they light when the pin is LOW, and the USB core flashes them when data moves.
I2C, and SPI on the ICSP header
Wire.begin() puts I2C on pin 2 for SDA and pin 3 for SCL, and the two holes beside AREF are the same pins. An Uno shield that uses A4 and A5 for I2C does not work on a Leonardo without two jumpers. A sketch that uses pins 2 or 3 for something else loses the bus.
On a Leonardo, SPI is only on the six-pin ICSP header, and SCK, MISO, MOSI and SS are 15, 14, 16 and 17, pins that have no hole on the main headers. Mokxi draws the ICSP header with its six pads, and its SPI.h runs the bus in software on the same pins. The sketch below printed "SCK 15, MISO 14, MOSI 16, SS 17" here. Wire an SPI module’s SCK, MISO and MOSI to the ICSP pads, not to 13, 12 and 11 as on an Uno. SS, pin 17, is the RX lamp’s pin and has no pad, so use any free pin for chip select.
void show(const char *name, long value) {
Serial.print(name);
Serial.print(' ');
Serial.println(value);
}
void setup() {
Serial.begin(9600);
show("SDA", SDA);
show("SCL", SCL);
show("LED_BUILTIN", LED_BUILTIN);
show("A6", A6);
show("A11", A11);
show("INT on 7", digitalPinToInterrupt(7));
show("SCK", SCK);
show("MISO", MISO);
show("MOSI", MOSI);
show("SS", SS);
}
void loop() {
}PWM, A6 to A11, and the interrupts
Seven pins do PWM with analogWrite: 3, 5, 6, 9, 10, 11 and 13. Pin 13 runs at 976 Hz from timer 4, a ten-bit timer an Uno does not have, and pin 9 at 490 Hz from timer 1. Mokxi models both timers.
The same sketch printed "SDA 2, SCL 3, LED_BUILTIN 13, A6 24, A11 29, INT on 7 4". A6 to A11 are second names for digital pins 4, 6, 8, 9, 10 and 12, in that order, so analogRead(A9) reads pin 9; driving each pin high in turn, the matching name read 1023 and the others 0. attachInterrupt works on 3, 2, 0, 1 and 7, which are interrupts 0 to 4, so always pass the pin through digitalPinToInterrupt(): pin 7 is interrupt 4, not 7.
Which pin should I use for what?
An LED to dim: 5, 6, 9, 10, 11 or 13. A button with an interrupt: 7, which leaves Serial1 and I2C alone. Any other button: 4, 8 or 12 with INPUT_PULLUP. An analog sensor: A0 to A5, or A6 to A11 if they run out. An I2C module: 2 and 3, or the SDA and SCL holes. An SPI module: the ICSP header, with chip select on any free pin. A serial device: 0 and 1 as Serial1.
Questions
What are the Arduino Leonardo I2C pins?
Pin 2 is SDA and pin 3 is SCL, and the SDA and SCL holes beside AREF are the same two pins. Not A4 and A5, as on an Uno.
Where are the SPI pins on a Leonardo?
Only on the ICSP header: MISO on pin 1, SCK on pin 3 and MOSI on pin 4. Pins 11, 12 and 13 are not SPI on a Leonardo, in Mokxi or on a desk.
Which Leonardo pins are PWM?
3, 5, 6, 9, 10, 11 and 13. Pin 13 can fade, which it cannot on an Uno.
Which pins have interrupts on a Leonardo?
0, 1, 2, 3 and 7. Pin 7 is interrupt 4, so write `attachInterrupt(digitalPinToInterrupt(7), handler, FALLING)`.
Why does Serial not come out of pins 0 and 1?
`Serial` is the USB socket on a Leonardo. Pins 0 and 1 are `Serial1`, a separate port.
How many analog pins does the Leonardo have?
Twelve: A0 to A5 on the bottom header, and A6 to A11 on digital pins 4, 6, 8, 9, 10 and 12.
Keep going
Where the facts on this page come from
Build this for real
Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.