The Arduino Leonardo (Rev3b) is a versatile microcontroller board that is based on the ATmega32U4. Unlike other Arduino boards, the Leonardo has the advantage of having built-in USB communication, which allows it to emulate a computer keyboard, mouse, or MIDI device without the need for an additional USB-serial converter. This feature makes the Leonardo particularly suitable for projects that require human interface device (HID) capabilities or MIDI interfaces.
Common applications for the Arduino Leonardo include:
Pin Number | Function | Description |
---|---|---|
1-7 | Digital I/O | Digital pins, PWM available on pins 3, 5, 6, 9, 10, 11, 13 |
8-12 | Analog Input | Analog input pins, can also be used as digital I/O |
13 | LED_BUILTIN | Pin connected to the built-in LED, can be used as digital I/O |
A0-A5 | Analog Input | Additional analog input pins, can also be used as digital I/O |
A6-A11 | Analog Input | Analog input pins only (not available on headers) |
RX/TX | Serial Comm. | Pins used for serial communication (0 and 1) |
SDA/SCL | I2C Comm. | Pins for I2C communication (2 and 3) |
AREF | Analog Ref. | Analog reference pin for ADC conversions |
GND | Ground | Ground pins |
RST | Reset | Reset pin, can be used to restart the microcontroller |
3.3V | Voltage Supply | 3.3V regulated output from onboard regulator |
5V | Voltage Supply | 5V regulated output from onboard regulator |
VIN | Voltage Input | Input voltage to the Arduino board |
To use the Arduino Leonardo in a circuit:
Here is a simple example of how to blink the built-in LED on the Arduino Leonardo:
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;
// The setup routine runs once when you press reset:
void setup() {
// Initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// The loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // Turn the LED on (HIGH is the voltage level)
delay(1000); // Wait for a second
digitalWrite(led, LOW); // Turn the LED off by making the voltage LOW
delay(1000); // Wait for a second
}
This code will blink the built-in LED on and off every second. It's a great starting point for testing your Arduino Leonardo and ensuring it's functioning correctly.
Q: Can the Leonardo be used as a USB host? A: No, the Leonardo functions as a USB device, not a host.
Q: How do I reset the Leonardo? A: Briefly press the reset button on the board.
Q: Is the Leonardo compatible with all Arduino shields? A: Most shields designed for the Uno will work with the Leonardo, but check for compatibility, especially regarding pin usage and layout.
For further assistance, consult the Arduino forums and the extensive community resources available online.