An Open-Source platform to create digital devices and interactive objects that sense and control physical devices. | Arduino Tutorials | |
Arduino Projects |
Arduino Comparison Chart: Boards & Modules
The above schematic is provided to demonstrate what you would need to do to build your own board. Coming up with the Arduino required taking an off the shelf microcontroller, using a lot of extra parts, and putting it together in a way that is simple to use. The genius behind the Arduino is the hard work is done for you, and the microcontroller is designed to be easily programmable through the Arduino IDE.
To do anything useful with the Arduino you will need to know the various parts of the circuit board.
It is notable for its inclusion of more digital and analog pins.
The Leonardo was the first Arduino to use Atmel's ATmegaXU4 series chip with built-in USB.
ATmega 32U4 Pin Mapping
The 20 digital i/o pins of the Leonardo can be used as input or output using the pinMode(), digitalWrite(), and digitalRead() functions. Each operates at 5 V and can provide or receive a maximum of 40 mA. It has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.
The Following Pins have specialized functions:
Serial: Pin 0 is used for receiving (RX) and Pin 1 is used for transmitting (TX) TTL serial data using the ATmega32U4 hardware serial capability. On the Lenoardo, serial Class refers to USB (CDC) communications; for TTL serial on pins 0 and 1, use the Serial1 class.
TWI: Pin 2 (SDA) and Pin 3 (SCL) support TWI communication using the Wire Library. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value.
SPI (Serial Peripheral Interface) Pins: There is no exposed pin for SS but you could use digital Pin 10 as it is next to the other pins. You could also use MOSI - Master Out/Slave In as digital 11, MISO - as digital 12, and SCK as digital 13.
These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector.
This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo’s 6-pin ICSP header, the shield will not work.
- MISO (Master In Slave Out) - This is the line that carries data from the Leonardo to the SPI-controlled device(s).
- MOSI (Master Out Slave In) - This line carries data from the SPI device back to the Leonardo
- SS (Slave Select) - This tells the device on the bus we wish to communicate with it . Each SPI device needs a unique SS line back to the Arduino.
- SCK (Serial Clock) - The clock pulses which synchronize data transmissions generated by the master
As you can see from the image above, on the Leonardo the SPI pins are located on the ICSP header Pins:
Arduino Board | MOSI | MISO | SCK | SS (slave) | SS (Master) | Level |
---|---|---|---|---|---|---|
Leonardo | ICSP - 4 | ICSP-1 | ICSP-3 | - | - | 5V |
LED: Built-in LED is connected to pin 13. Setting the pin to HIGH value turns the LED on and setting it LOW means its off.
Analog Inputs: A0-A5, A6 – A11 (on digital pins 4, 6, 8, 9, 10, and 12). The Leonardo has 12 analog inputs, labeled A0 through A11, all of which can also be used as digital i/o. Pins A0-A5 appear in the same locations as on the Uno; inputs A6-A11 are on digital i/o pins 4, 6, 8, 9, 10, and 12 respectively. Each analog input provide 10 bits of resolution (i.e. 1024 different values). By default the analog inputs measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.
You can map analog pins as digital using the following code:
// Mapping of analog pins as digital I/O
// A6-A11 share with digital pins
static const uint8_t A0 = 18;
static const uint8_t A1 = 19;
static const uint8_t A2 = 20;
static const uint8_t A3 = 21;
static const uint8_t A4 = 22;
static const uint8_t A5 = 23;
static const uint8_t A6 = 24; // D4
static const uint8_t A7 = 25; // D6
static const uint8_t A8 = 26; // D8
static const uint8_t A9 = 27; // D9
static const uint8_t A10 = 28; // D10
PWM: Pins 3, 5, 7, 9, 10, 11, and 13 provide 8 bit PWM output with the analogWrite() function
Pin 13 - drives the built in LED, that is used by Arduino to receive power and useful for debugging. When pin is HIGH value, the LED is on, when pin is LOW value, it's off.
Analog Reference Pin (AREF) - input pin used optionally if you want external voltage reference for ADC rather than internal Vref. You can configure using an internal register.
Reset Pin - bring this line low to reset the microcontroller. Typically used to add a reset button to shields that block the one on the board.