The Arduino Leonardo board use an ATmega32U4 to offer you more functionalities compared to Uno
Not only does this AVR chip offer built-
The Leonardo is a great addition to the Arduino family. It sports more pins, faster PWM, lots of analog input pins and best of all true USB.
More Digital Pins
There are 4 extra digital pins. The Arduino Uno has 14 digital pins – D0-
To gain access to the additional four pins, the first three have been mapped to the ICSP header.
Instead of the ICSP pins corresponding to pins D11-
D14 – MISO – PB3
D15 – SCK – PB1
D16 – MOSI – PB2
D17 – SS – PB0
The last pin, D17 (SS), does not have a corresponding pin on the ICSP header, nor anywhere on the board. In order to use it, you must solder a wire to either the end of the Rx LED or the via attached to it.
More and Better PWM Pins
While only one extra PWM pin is available (the Leonardo has 7, the Uno has 6), the timers on the ATmegaXU4 are considerably more capable.
On the ATmegaXU4 there are: one 8-
There are a total of 9 pins supporting independent timer output, 2 of the pins are shared, leaving 7 pins total for PWM.
More Analog Pins
In the ATmegaxx8 based Arduinos, such as the Uno, there 6 analog input pins that can also be used as digital pins. In the Leonardo, there are a whopping 12 analog input pins which can also be used for digital pins.
In order to maintain compatibility with existing Arduino shields, analog pins A6-
They are marked with a dot on the top side of the board with the numbering drawn on the backside. The correspondence with their digital counterparts is as follows:
A6 – D4
A7 – D6
A8 – D8
A9 – D9
A10 – D10
A11 – D12
The original 6 analog input pins have new digital pins mappings as well. They are:
A0 – D18 A1 – D19 A2 – D20 A3 – D21 A4 – D22 A5 – D23
In order to use these analog pins, you must of course forgo using them as digital pins. However, since you also get four new digital pins, the trade-
The pins supporting I2C/TWI used to be the same as analog pins A4 & A5. In order to use this service, you had to forgo two precious analog pins. In the Leonardo, these protocol pins are now located at digital pins D2 & D3. They also still have their own special place in the output headers just like the Uno.
Serial Port Differences
The standard serial port at pins D0 (Rx) and D1 (Tx) have become a second serial port.
The primary serial port is implemented as part of the USB interface and uses no digital pins.
The Rx & Tx LEDs are tied to the first serial port and are not active when using the second one.
In software, the primary serial port is still accessed using the object Serial. To access the second serial port, use a new object called Serial1 in the same manner.
There are also some differences in how the primary serial port acts when attached to your computer.
Formerly, when the serial port was implemented in hardware, resetting the Arduino had no effect at the computer end. Now, the serial port is a creation of software.
Therefore, when the Arduino is reset, the connection is broken and a new serial port is established.
The Leonardo is an instance of USB’s Connected Device Class (CDC) driver.
This means that every time you reset the board, the Leonardo’s USB serial connection will be broken and re-
The Leonardo will disappear from the list of serial ports, and the list will re-
Any program that has an open serial connection to the Leonardo will lose its connection.
This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection
The other key difference with the virtual serial port is that when you open the serial monitor in the Arudino IDE, it doesn’t trigger a reset on your board.
This change means you won’t see serial data that has already been sent since your sketch started.
Now that the Leonardo supports USB directly, that means it can operate as an actual USB device.
Two of the tricks it can do is to emulate either a computer mouse or a keyboard. It can even emulate both.
The Arduino library has made it really easy to do by creating a Mouse class and a Keyboard class.