Arduino Micro Board Pins

Source: Arduino.cc
The Micro and Leonardo boards share the same ATmega32U4 microprocessor and the same board architecture, so this write-up applies equally to both boards.

Starting work with the Arduino I quickly ran into trouble understanding the board pins, particularly in terms of how to work with them within the sketches. First, the board itself has a very tiny silkscreen name by each pin. If you were to, like I did, try to use those pin names in a function call, such as pinMode(D2, INPUT), the sketch will not compile. In the picture to the right, the integers and alias names in red provide the alias or integer to use in your code. From this, the earlier code fragment above would be pinMode(2, INPUT)0 or pinMode(SDA, INPUT).

Before I made the connections in my mind from the data in the board image here, I spent some time poking into the board-specific header files in the Arduino installation. The Leonard board header, which is called by the Micro board header is at Arduino\hardware\arduino\avr\variants\leonardo\pins_arduino.h. Where there are two integers or aliases seperated by a slash (/), the first is the digital reference and the second is the analog reference.


Board NamePORTPINAlternate Names/FunctionsIntegerAlias
MOSIB2D16, PB2, MOSI, PCINT216MOSI
SSB0D17, PB0, RXLED, SS, PCINT017SS
TXD3D1, PD3, TXD1, INT31TX
RXD2D0, PD2, RXD1, INT20RX
D2D1PD1, SDA , INT12SDA
D3D0PD0, PWM8, SCL, OC0B, INT03SCL
D4D4A6, PD4, ADC84/244/A6
D5C6PC6, OC3A, OC4A5
D6D7A7, PD7, FastPWM, OC4D, ADC106/256/A7
D7E6PE6, INT6, AIN07
D8B4A8, PB4, ADC11, PCINT48/268/A8
D9B5A9, PB5, PWM16, OC1A, OC4B, ADC12, PCINT59/279/A9
D10B6A10, PB6, PWM16, OC1B, 0C4B, ADC13, PCINT610/2810/A10
D11B7PB7, PWM8/16, 0C0A, OC1C, RTS, PCINT711
D12D6A11, PD6, T1, OC4D, ADC912/2911/A11
D13C7PC7, PWM10, CLK0, OC4A13
A0F7D18, PF7, ADC718
A1F6D19, PF6, ADC619
A2F5D20, PF5, ADC520
A3F4D21, PF4, ADC421
A4F1D22, PF1, ADC122
A5F0D23, PF0, ADC023
MISOB3D14, PB3, MISO, PCINT314MISO
SCKB1D15, PB1, SCK, PCINT115SCK

It took a frustratingly long time to figure that out. Also frustrating is that not all of the I/O pins have an alias. I've hacked together a short header file that can be used to give the pins relevant alias that match both the silk screened pin names on the board and the alternate functions I've dug out of the pins_arduino.h header file for the Leonardo boards.

No comments:

Post a Comment