Arduino Leonardo- based controllerATmega32u4 (technical description, pdf). The platform has 20 digital I/Os (7 of which can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connector, a power connector, an ICSP connector, and a reset button. To work, you need to connect the platform to the computer using a USB cable, or supply power using an AC/DC adapter or battery.
Unlike all previous boards ATmega32u4has built-in support for USB connection, this allows you to specify howLeonardo will be visible when connected to a computer, it can be a keyboard, mouse, virtual serial/COM port.
Characteristics
Microcontroller
|
ATmega32u4
|
Working voltage
|
5 in
|
Input voltage (recommended)
|
7-12V
|
Input voltage (limit)
|
6-20V
|
Digital Inputs/Outputs
|
20 (7 of which can be used as outputs PWM)
|
Analogue channels
|
12 |
Constant current through input/output
|
40 mA
|
DC current for 3.3V pin
|
50 mA
|
Flash memory
|
32KB (ATmega32u4) of which 4KB is used for bootloader
|
RAM
|
2 KB (ATmega32u4)
|
EEPROM
|
1 KB (ATmega32u4)
|
Clock frequency
|
16 MHz
|
Scheme and initial data
EAGLE files:arduino-leonardo-reference-design.zip
Schematic diagram:arduino-leonardo-schematic-rev3b.pdf
Food
Arduino Leonardocan be powered via a USB connection or from an external power source. The power supply is automatically selected.
External power (not USB) can be supplied via an AC/DC converter (power supply) or battery. The voltage converter is connected via a 2.1 mm plug with a center positive pole. The battery wires are connected to the Gnd and Vin pins of the power connector.
The platform can operate with an external power supply of 6V to 20V. If the supply voltage is below 7V, the 5V pin may output less than 5V, and the platform may be unstable. When using voltages above 12V, the voltage regulator may overheat and damage the board. The recommended range is 7V to 12V.
Power pins:
-
VIN... The input is used to supply power from an external source (in the absence of 5V from a USB connector or other regulated power supply). The supply voltage is supplied through this pin.
-
5V... A regulated voltage source used to power the microcontroller and components on the board. Power can be supplied from the VIN pin through a voltage regulator, or from a USB connector or other regulated 5V voltage source.
-
3V3... The voltage at pin 3.3V is generated by the onboard regulator on the board. Maximum current consumption 50 mA.
-
GND... Ground leads.
-
IOREF... Output with operating voltage input/outputs of the board. ForLeonardoThis is 5 V. It is supposed to be used by expansion boards for the correct selection of the operating voltage.
Memory
The ATmega32u4 microcontroller has 32 KB of flash memory, of which 4 KB is used for storing the bootloader, as well as 2.5 KB of RAM (SRAM) and 1 KB of EEPROM. (Which is read and written usingEEPROM libraries).
Inputs and Outputs
Each of the Leonardo's 20 digital pins can be configured as input or output using the functions pinMode(), digitalWrite(), anddigitalRead(),. The pins operate at 5 V. Each pin has a pull-up resistor (disabled by default) of 20-50 kΩ and can pass up to 40 mA. Some pins have special functions:
-
Serial bus: 0 (RX) and 1 (TX)... The pins are used to receive (RX) and transmit (TX) TTL data. These pins are connected to the corresponding pins on the ATmega32U4 USB-to-TTL serial chip. Please note thatLeonardo, classSerialrefers to the USB CDC serial connection. Serial connection through pins 0 and 1 is done through the classSerial1.
-
TWI: 2 (SDA) and 3 (SCL)... The pins provide I2C (TWI) communication using the Wire library.
-
External interrupt: 2 and 3... These pins can be configured to trigger an interrupt on either a low value, a rising or falling edge, or when the value changes. Details are in the function descriptionattachInterrupt().
-
PWM: 3, 5, 6, 9, 10, 11 and 13.Any of the conclusions providesPWMwith 8 bit resolution using the functionanalogWrite().
-
SPI: on ICSP header.Through these pins, SPI communication is carried out, for which it is usedSPI library... Note that the Leonardo's SPI pins are not routed to digital I/O as they were in previous versions of Arduino controllers.
-
LED: 13. Built-in LED connected to digital pin 13. If the pin is high, the LED is on.
-
Analog inputs: A0-A5, A6-A11 (on digital pins 4, 6, 8, 9, 10 and 12). Leonardo has 12 analog inputs labeled A0 to A11. All analog inputs can operate as digital I/O. Inputs A0 to A5 are the same as analog inputsUNO... Inputs A6 to A11 on digital pins 4, 6, 8, 9, 10, and 12, respectively. Resolution of analog inputs - 10 bits, i.e. 1024 different values. The default value on the analog inputs is measured from ground (0) to 5 Volts, the upper range limit can be changed using the AREF input andanalogReference()functions.
Additional pair of platform pins:
-
AREF.Reference voltage for analog inputs. Used with the functionanalogReference().
-
Reset. A low signal level at the pin reboots the microcontroller. Usually used to connect a reset button on an expansion board, which prevents access to the button on the Arduino board itself.
Pay attention to the connection between the pinsArduino and ATmega328 ports.
Communication
On the platformArduino Leonardocan communicate with a computer, other Arduino devices or microcontrollers in several ways. The ATmega32U4 supports UART TTL (5V) serial interface via pins 0 (RX) and 1 (TX). The ATmega32U4 also allows you to set up a serial connection with programs on the computer side via USB so that they "communicate" with the board via a virtual COM port. Leonardo can be connected as a USB 2.0 device using standard USB COM drivers (Windows requires an .inf file). Serial MonitorArduino development environmentsallows you to send and receive text data when connected to the platform. The RX and TX LEDs on the platform will flash when transmitting data over a USB connection (but not when using serial transmission on pins 0 and 1).
With the SoftwareSerial library it is possible to create serial data transmission via any of the Leonardo digital pins.
The ATmega32U4 supports I2C (TWI) and SPI interfaces. The Arduino includes a Wire library for the convenience of using the I2C bus. For SPI can be usedSPI library.
Arduino Leonardo can be detected when connected to a computer as a mouse or keyboard device. This mode is controlled through the Keyboard and Mouse classes.
Programming
The platform is programmed using Arduino software. From the menu Tools > Board"Arduino Leonardo" is selected (according to the installed microcontroller). Details are inreference bookandinstructions.
The ATmega32U4 microcontroller on the Leonardo comes with a pre-recorded bootloader, making it easy to write new programs without using external programmers. Communication is carried out by the AVR109 protocol.
It is possible not to use a bootloader and program the microcontroller via ICSP pins (in-circuit programming). Details are inof this manual.
Automatic (software) reboot
Leonardois designed in such a way that before writing a new code, the reboot is carried out by the Arduino program itself on the computer, and not by pressing a button on the platform. Reboot is triggered when the virtual CDC COM port opens at 1200 baud and then closes. When this happens, the microprocessor goes to reboot, breaking the USB connection. After the reboot, the bootloader (bootloader) starts and remains active for about 8 seconds. The bootloader can also be initiated by pressing the Reset button. Note that when power is applied, the controller immediately proceeds to execute the loaded user program without executing the bootloader.
USB connector overcurrent protection
INArduino Leonardoa self-restoring fuse (automatic) is built-in, which protects the USB port of the computer from short-circuit currents and overcurrents. Although virtually all computers have this type of protection, this fuse nonetheless provides an additional barrier. The fuse is triggered when a current of more than 500 mA passes through the USB port and opens the circuit until the normal values of the currents are restored.
physical characteristics
The Leonardo PCB measures 6.9 x 5.3 cm. The USB and power connectors are outside of these dimensions. Four holes in the board allow it to be fixed to a surface. The distance between digital pins 7 and 8 is 0.4 cm, although it is 0.25 cm between the other pins.