I just got an arduino Leonardo, and on the product page, it says it has 20 digital I/O pins and 12 analog. I can only see 14 digital and 6 analog. Are they missing or something?
I know I can use the analog pins as digital pins, so if I use all as digital, i get 20. But on the Uno, I can do the same, and on that product page, it only says 14.
So is it a typo, or is it something else with these boards?
It has the 14 normal pins, two addititional i2c pins, three spi pins? Unlike UNO, the spi and i2c pins are not simply aliases for other pins. I think.
Or it could be counting 14 pure digital pins + 6 analog pins that can be used as digital pins as well...
The Leonardo has 12 analog inputs. The first 6 are mapped on pins A0..A5 that you can read on the top of the board and are separated pins. The other 6 pins are named A6..A11 and are mapped on some other digital pins: you can see this on the bottom of the board.
Like the UNO, analog pins can be used like digital pins. So the Leonardo has 20 digital I/O lines (D0..D13+A0..A5) and 12 analog inputs (A0..A11). But, of course, you cannot use all of those pins at the same time, but it's correct to say that the board has 20 I/O lines: you just have 20 pins (14D+6A) on the top of the board free for use.
Aha, I see. But what about the Uno? It can also use the analog as digital pins. I have done it some times with no problem at all. So why does it not stand on the uno 20 digital pins?
Only the actual Arduino members really know for sure why they decided to list the I/O counts differently between the two products. Neither way is inaccurate, but both are not a complete description of I/O capabilities by themselves.
I was toying with this for a Leonardo clone layout - making D0/D1, I2C, and SPI pins compatible with existing shield pins, and bringing out the 6 new pins.
Eventually it morphed into the dual sided Leonardino board instead, with uSD card.