Leonardo analog pins as digital

Hey, so I’m trying to use the analog pins as digital but I can’t make them work.
I’m using this library (Arduino Leonardo/Micro As Game Controller/Joystick : 10 Steps - Instructables) so it recognizes it as a joystick, digital pins work fine and analog pins A0-A5 work well with a potentiometer.
I dont’t know whether to map the analog pins as A0 or pin 14 and then why are they not working, also when I use pin 13 the only thinng that happens is the L led turns on.
NOTE: I’m using INPUT_PULLUP for all the pins.
Thanks

It would help if You show the code. Use "code tags". If Your are uncertain about that, read the first topice telling "How to use forum", how to attach code.
I can't tell if You need to do a digitalRead(14) or You can use a digitalRead(A0). A0 in some respekts works as digital(14) regarding to the compiler.
Good You have found the "INPUT_PULLUP"! I'm uncertain but maybe it works for A0 - A5.
Make some single test sketch!es!

pedroche:
I dont't know whether to map the analog pins as A0 or pin 14 and then why are they not working, also when I use pin 13 the only thinng that happens is the L led turns on.
NOTE: I'm using INPUT_PULLUP for all the pins.
Thanks

A0 is not digital pin 14. That is true on the Uno, but not on the Leonardo. Here are the definitions for the Leonardo:

// Mapping of analog pins as digital I/O
// A6-A11 share with digital pins
#define PIN_A0   (18)
#define PIN_A1   (19)
#define PIN_A2   (20)
#define PIN_A3   (21)
#define PIN_A4   (22)
#define PIN_A5   (23)
#define PIN_A6   (24)
#define PIN_A7   (25)
#define PIN_A8   (26)
#define PIN_A9   (27)
#define PIN_A10  (28)
#define PIN_A11  (29)

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;	// D4
static const uint8_t A7 = PIN_A7;	// D6
static const uint8_t A8 = PIN_A8;	// D8
static const uint8_t A9 = PIN_A9;	// D9
static const uint8_t A10 = PIN_A10;	// D10
static const uint8_t A11 = PIN_A11;	// D12

My recommnedation is to always use the label written on the board. That avoids this confusion of "I can't remember was the digital pin number of A0 14 or 18 on the Leonardo?".

Railroader:
Good You have found the "INPUT_PULLUP"! I'm uncertain but maybe it works for A0 - A5.
Make some single test sketch!es!

Yes, all the digital pins have internal pullup resistors you can set via pinMode().

But it's definitely worth setting up some simple experiments to explore how the pins work. I do this all the time with an LED for outputs or a jumper wire standing in as a button for inputs.

pert:
A0 is not digital pin 14. That is true on the Uno, but not on the Leonardo. Here are the definitions for the Leonardo:
ArduinoCore-avr/pins_arduino.h at 1.8.3 · arduino/ArduinoCore-avr · GitHub

// Mapping of analog pins as digital I/O

// A6-A11 share with digital pins
#define PIN_A0  (18)
#define PIN_A1  (19)
#define PIN_A2  (20)
#define PIN_A3  (21)
#define PIN_A4  (22)
#define PIN_A5  (23)
#define PIN_A6  (24)
#define PIN_A7  (25)
#define PIN_A8  (26)
#define PIN_A9  (27)
#define PIN_A10  (28)
#define PIN_A11  (29)

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6; // D4
static const uint8_t A7 = PIN_A7; // D6
static const uint8_t A8 = PIN_A8; // D8
static const uint8_t A9 = PIN_A9; // D9
static const uint8_t A10 = PIN_A10; // D10
static const uint8_t A11 = PIN_A11; // D12



My recommnedation is to always use the label written on the board. That avoids this confusion of "I can't remember was the digital pin number of A0 14 or 18 on the Leonardo?".
Yes, all the digital pins have internal pullup resistors you can set via pinMode().

But it's definitely worth setting up some simple experiments to explore how the pins work. I do this all the time with an LED for outputs or a jumper wire standing in as a button for inputs.

Thanks a lot! As You scan guess I'm an UNO-guy, but I've ordered a cheap Mega to learn more... Here it was a Leonardo and it's different.

The none digital pins, A0 -A5 needs external pullup in order to be used i a way like digital input. Read analog and compare againt 512....

Railroader:
The none digital pins, A0 -A5 needs external pullup in order to be used i a way like digital input. Read analog and compare againt 512....

You can just use the normal digitalRead() on these pins:

Serial.println(digitalRead(A0));

The "analog" is just an additional special characteristic of the pins, sort of like how the PWM pins are normal digital pins, but with the capability to also be used with analogWrite().

The exceptions are A6 and A7 on the Nano and Pro Mini. Unlike the other "analog" pins, those pins are ADC-only, so you do need to use analogRead() on those pins even when their ADC functionality is not needed.

pert:
You can just use the normal digitalRead() on these pins:

Serial.println(digitalRead(A0));

The "analog" is just an additional special characteristic of the pins, sort of like how the PWM pins are normal digital pins, but with the capability to also be used with analogWrite().

The exceptions are A6 and A7 on the Nano and Pro Mini. Unlike the other "analog" pins, those pins are ADC-only, so you do need to use analogRead() on those pins even when their ADC functionality is not needed.

Ehh. Connecting things like a button closing as active, open as inactive, every input, analog or digital, is floating as inactive. Don't You think a pullup is needed then?
So many new members have problems with "buttons" and pull up/down is too often a reason for the failure. Therefore my suggestion.

Railroader:
Ehh. Connecting things like a button closing as active, open as inactive, every input, analog or digital, is floating as inactive. Don't You think a pullup is needed then?

Of course. We're in complete agreement on that.

What we're in disagreement on is this part:

Railroader:
Read analog and compare againt 512....

There is no need to read analog. Just use digitalRead().

pert:
Of course. We’re in complete agreement on that.

What we’re in disagreement on is this part:There is no need to read analog. Just use digitalRead().

Thanks again. Being uncertain, analogRead felt like safe, lacking specific knowledge all the way…