Leonardo - D14 to D19 - Where are they !!!

Hi !

looking at the specs of the Leonardo, and it mentions that it has 20 Digital IOs + 12 AIs

On the pinout diagram, I can only see D0 to D13

To access D14 to D19, does it mean that I have to use A0 to A5 as Digital IO ???

Then it is not really true that the Leonardo has 20 DIO and 12 AI !!

I don’t know what you have been reading but http://arduino.cc/en/Main/ArduinoBoardLeonardo says

The Arduino Leonardo is a microcontroller board based on the ATmega32u4 (datasheet). It has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs)

ok...

kinda confusing, because I normally "play" with the Nano: It is supposed to have 14 DIO and 8 AI, and that's what it has !

No BS about DIO that are AI or vice-versa !

Thanks !

On the NANO A0-A5 can also be used as digital pins.

Nicoverduin: on the Nano, I assume that A0-A5 can only be used as outputs, and you either write a value of 0 or 255

Correct ??

The NANO has the same chip as the Arduino UNO. However on the UNO, A6 & A7 are not connected to pins thus not reachable. For the rest they are from a processor perspective the same. Thus the NANO has: 14 Digital pins, 6 Analog pins to be use as Analog input, digital input or digital output, 2 analog input pins (A6 & A7). So your assumption is wrong.

jasmino: Nicoverduin: on the Nano, I assume that A0-A5 can only be used as outputs, and you either write a value of 0 or 255

Correct ??

No. A0-A5 can be used for analogRead(), digitalRead(), and digitalWrite(). They can't be used for analogWrite(). A6 and A7, on the other hand, can only be used for analogRead(). They are only inputs to the analog input multiplexer and don't have corresponding digital I/O hardware.

johnwasser: when I write to a DO, I use 0 to 13

e.g.:

digitalWrite(13, HIGH)

if I want to use A0-A5 as Digital Out, what number should I use ?

I saw a few article: I tried 14, A0 without success. I also defined it as OUTPUT - no luck ! Is it possible that this "trick" is only possible with the Uno, not the Nano ???

What about using them as Digital Input ? Can you give an example ?

Thanks !

jouellet: if I want to use A0-A5 as Digital Out, what number should I use ?

You can refer to them either by A0-A5 or 14-19.

It was pointed out to me recently though, that A0-A5 is better for transportability. Those pins will be A0-A5 on any board, but not necessarily 14-19.

Hi !

this is the code that I'm trying on a Nano:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(13, OUTPUT); 
  pinMode (A0, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(A0, HIGH); 
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(A0, LOW);
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
}

It does not work ...any idea why ?

It does not work ...

Please explain what you mean exactly. What happens when you run the program and how is the LED on A0 wired ? It works fine here.

That code should work fine to turn A0 HIGH (5V) and LOW (0V). Does the LED blink as expected? How are you checking A0? Does the method you use to check A0 work on D13?

const int LEDPin = 13;
const int OtherPin = A0;

// the setup routine runs once when you press reset:

void setup() {                
  // initialize the digital pin as an output.
  pinMode(LEDPin, OUTPUT); 
  pinMode (OtherPin, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(OtherPin, HIGH); 
  digitalWrite(LEDPin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for half a second
  digitalWrite(OtherPin, LOW);
  digitalWrite(LEDPin, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for half a second
}

nicoverduin: The NANO has the same chip as the Arduino UNO. However on the UNO, A6 & A7 are not connected to pins thus not reachable. For the rest they are from a processor perspective the same. Thus the NANO has: 14 Digital pins, 6 Analog pins to be use as Analog input, digital input or digital output, 2 analog input pins (A6 & A7). So your assumption is wrong.

They aren't the same chip.

The Nano uses the 328P-AU, which is a 32-TQFP (SMD) chip, while the regular UNO uses the 328P-PU, which is a 28-DIP (TH) chip.

The 328P-AU has 2 pins that the 328P-PU lacks: ADC6 and ADC7, which became A6 and A7.

Only on the SMD version of the UNO it is possible to expose these 2 pins with a hardware hack. They are there, but not connected to any header.

On the DIP version of the UNO these pins simply don't exist.

In short: in any board using a 328P-AU (SMD) it is possible to use the ADC6 (pin 19) and ADC7 (pin 22) pins.

The 328P-AU also has 1 more VCC and 1 more GND pin, that are absent in the DIP version.

You are probably mistaking ADC6/ADC7 for PB6/PB7, which exist on both chips, but are used for the cristal/oscillator/ressonator. If you run the 328P (-PU or -AU) using the chip's internal oscillator, therefore at 8Mhz max, you can turn those 2 pins into usable analog pins (PORTB 6 and 7). However, on ANY 16-Mhz Atmega328[P] board, these 2 pins are used for the 16.0000Mhz cristal, and that includes the Nano.

Gents,

Sorry for the late reply : I'm affected by a disease called "poverty", that forces me to work....I was doing my daily "treatment" !!!

jokes aside, when I push my sketch, D13 flashes, but A0 does not.

I have connected a LED with a 330 resistor onto A0. If I move it to D13, it flashes...

When I look at the Leonardo's specs, it says "It has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs)"

The Uno, on the other hand, says: "It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs"

They do not mention specifically that pins can either be digital or Analog....

And I could no longer find the specs for the Nano.

Is it possible that Analog pins on the Nano are Analog In only ???

never mind !

it works...I was using some kind of "sensor board" and the pinout on the analog side was reversed...

I'm going to take whatever is left of my pride to get a beer and wonder how I became so dumb....

thanks for your help !