Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
Overview
The Arduino Leonardo is a microcontroller board based on the ATmega32u4. It has 20 digital input/output pins (7 of which can be used for PWM output and 12 can be used for analog input), a 16 MHz crystal oscillator, a Micro USB interface, a DC interface, an ICSP interface, and a reset button. It includes everything needed to support the microcontroller, and you can simply connect it to a computer's USB port, or use an AC-DC adapter, or run it on a battery.
Leonardo is different from all previous arduino controllers, he directly uses the USB communication function of ATmega32u4, and cancels the USB to UART chip. This allows the Leonardo to be connected to the computer not only as a virtual (CDC) serial/COM port, but also as a mouse or keyboard. It's also different in many ways, which we'll cover on the Getting Started page.
Features
Microcontroller : ATmega32u4
Working voltage : 5V
Input voltage (recommended) : 7-12V
Input voltage (limited) : 6-20V
Digital I/O Pins : 20
PWM channels : 7
Analog Input Channels : 12
Each I/O DC output capacity : 40mA
3.3V port output capability : 50mA
Flash : 32 KB (ATmega32u4) of which 4 KB is used by the bootloader
SRAM : 2.5KB (ATmega32u4)
EEPROM : 1KB (ATmega32u4)
Clock speed : 16MHz
Power supply
Arduino Leonardo can be powered by Micro USB interface or external power supply. The power source can be selected automatically.
External (non-USB) power can be from an AC-DC adapter (wall-wart) or batteries. The adapter plugs into a 2.1mm power outlet with a positive center to connect to the controller power supply. The wires from the battery can be plugged into the GND and VIN pins of the power connector.
An external power supply of 6V-20V can be input. However, if it is below 7V, the 5V pin will supply less than 5V and the control board may become unstable. If using a power supply greater than 12V the regulator may overheat and damage the board. The recommended range is 7V-12V.
The power pins are as follows:
Use external power for VIN (not 5V from a USB connection or other regulated power supply). You can supply the voltage through this pin, or, use the voltage input from the power socket through this pin.
The 5V regulated power supply is what powers the microcontroller and other components on the board. Can be supplied from the VIN input through the on-board regulator, or via USB or other regulated 5V supply.
3V3 The on-board voltage regulator generates a 3.3V supply. The maximum current is 50mA.
GND Ground pin.
The IOREF voltage works on the board's I/O pins (connected to VCC on the board, 5V on the Leonardo).
Storage
ATmega32u4 has 32KB of Flash (of which 4KB is used by the bootloader). It also has 2.5KB of SRAM and 1KB of EEPROM (reading and writing of EEPROM can refer to the EEPROM library).
Input and output
Each of the 20 I/O pins on the Leonardo can be used as input and output ports by using the pinMode(), digitalWrite(), and digitalRead() functions. Each pin has a 20-50 kohm internal pull-up resistor (disconnected by default), which can output or input a maximum current of 40ma. In addition, some pins have dedicated functions:
UART:0 (RX) and 1 (TX) Use the ATmega32U4 hardware serial port for receiving (RX) and sending (TX) TTL serial data. It should be noted that the Serial class of Leonardo refers to the communication of USB (CDC), while the TTL serial port of pins 0 and 1 uses the Serial1 class.
TWI:2 (SDA) and 3 (SCL) support TWI communication by using the Wire library.
External interrupts: 2 and 3, these pins can be configured
PWM:3, 5, 6, 9, 10, 11, and 13 can use the analogWrite() function to support 8-bit PWM output.
SPI:ICSP pin. SPI communication can be supported by using the SPI library. It should be noted that the SPI pins are not connected to any digital I/O pins like the UNO, they only work on ICSP ports. This means that if your shield is not connected to the ICSP pin on pin 6, it will not work.
LED:13. There is a built-in LED on digital pin 13, when the pin is high, the LED is on, and when the pin is low, the LED is off.
模拟输入:A0~A5, A6~A11 (digital pins 4, 6, 8, 9, 10, 12), Leonardo has 12 analog inputs, A0 to A11, all can be used as digital I/O ports. Pins A0-A5 are in the same position as the UNO; A6-A11 are digital I/O pins 4, 6, 8, 9, 10 and 12 respectively. Each analog input has 10-bit resolution (ie 1024 different values). By default, the analog input is 0-5V, and this upper limit can also be changed through the AREF pin.
Other pins:
AREF:Analog input signal reference voltage used by the analogReference() function.
Reset:Reset the arduino by setting this line low, usually used on expansion boards with a reset button.
Communication
To get the Leonardo to communicate with a computer, other arduinos, or other microcontrollers, there are various devices. On 0 and 1, ATmega32u4 provides UART TTL (5V) communication mode, and 32u4 also allows virtual serial (CDC) communication via USB virtual COM port on the computer. The chip uses standard USB serial drivers (requires an .inf file on Windows) and can act as a full-speed USB 2.0 device. The arduino software includes a serial monitor, which can send or receive simple data with the arduino board. When using USB to transmit data, the RX and TX LEDs on the board will blink (this feature is not applicable to ports 0 and 1).
The SoftwareSerial library enables serial communication with any digital I/O port.
ATmega32u4 also supports TWI (I2C) and SPI communication. The arduino software has a wire library for easy TWI (I2C) communication. SPI communication can use SPI library.
Leonardo can appear as a mouse, a keyboard, or can be programmed to control such keyboard and mouse input devices.
Programming
Leonardo can be programmed through arduino software, select Tool>board>Arduino Leonardo (choose according to your controller model). More references and tutorials.
Leonardo's ATmega32u4 chip has a bootloader programmed, which allows you to upload new programs to Leonardo without an external hardware programmer. The bootloader communicates using the AVR109 protocol.
You can also bypass the bootloader and use an external programmer to program through the ICSP (In-Circuit Serial Programming) pins.
Automatic reset and bootloader start
It is set in Leonardo that when uploading, the software establishes a connection to reset the controller, which saves us from manually pressing the reset button. When the Leonardo is running as a virtual (CDC) serial/COM port at 1200 baud, the reset function will be triggered and the serial port will be closed. At this point, the processor will reset and the USB connection will be disconnected (i.e. the virtual (CDC) serial/COM port will be disconnected). After the processor is reset, the bootloader starts immediately, and it takes about 8 seconds to complete this process. The bootloader can also be started by pressing the reset button on the board. Note that when the board is powered on for the first time, if there is a user program, it will directly jump to the user program area without starting the bootloader.
The best reset handling method for Leonardo is to let the arduino software try to start the reset function before uploading the program, instead of you manually clicking the reset button.
If the software does not automatically reset the control board, you can also manually press the reset button to reset the board and run the bootloader
USB overcurrent protection
The Leonardo has a resettable fuse that protects your computer's USB port against short circuits or overcurrent. While most computers come with built-in protection, fuses can also provide additional protection. If the current exceeds 500 mA, the fuse will automatically disconnect to prevent short circuit or overload.
Physical characteristics
The maximum length and width of Leonardo PCB are 2.7 inches and 2.1 inches respectively, surpassing the extended USB interface and power jack of the previous dimension. There are four fixing holes to fix the board to other surfaces or enclosures. Note that the distance between the 7 and 8 digital pins is 160mil (0.16"), not the 100 mil spacing like the other pins.