[solved ]I'm going crazy over this - digital input on analog pins

Fact: you can use analog pins as digital pins with funcions like digitalSomething
This short, simple code is supposed to print 'p' when an output pin is directly connected to an input pin.
And it works as long I use the digital input pins
But when I connect anything to A0 and A1 (which would be pin 14 and 15) nothing happens. Even if i connect them to ground

#include <Keyboard.h>

void setup() {
  
  int p;
 for(p=0;p<7;p++){
    pinMode(p,OUTPUT);
    }
for(p=7;p<16;p++){
    pinMode(p,INPUT);
    digitalWrite(p,HIGH);
    }

Keyboard.begin();
}

void loop() {
  int i,j;

  for(i=0;i<7;i++){
    digitalWrite(i,LOW);
    for(j=7;j<16;j++){
  int moby=digitalRead(j);
  if(moby==LOW){
    
    Keyboard.print('p');
    }
  delay(7);
  }
  digitalWrite(i,HIGH);
  delay(7);
  } 
}

Am I missing something??
Thank you

Yes, a wiring diagram, can you post it?
HowToPost

I literally use one single patch cable, which I move, connecting input and output pins toghether - I previously set them, in the setup() - directly on the board

So this Keyboard thing floats in midair then?

Please describe how everything is connected. In particular pins 0 and 1.

But when I connect anything to A0 and A1 (which would be pin 14 and 15)

On an Uno yes, but you didn't say that's what you have.

sertrincia:
directly on the board

I'm not sure if that means the Arduino or the keyboard, whatever that is.

Ok, I'm sorry for my lack of context.
Here is a photo.
With the function keyboard.print() included in the Keyboard.h library, I want to print a letter whenever an input pin is triggered to a LOW state, that is, when i connect the black cable from one end into an input pin, and the other end to an output pin or ground. This works on paper as there are 2 'for' cycles in the code that alternate the active pins.
Now while this perfectly works when I operate on all the digital i/o combinations, i can't wrap my head around the only two analog pins that i'm using, which don't work as intended. In the photo, for example the cable is connected from 3 (LOW output) to 14 or A0 (INPUT_PULLUP), but I get no 'p' on the notepad.
Are there some limitations on the analog pin uses?

(sorry for possible bad english)

Do a serial print of the pin's digitalRad() value to the monitor and see if it's changing as expected.

The Leonardo is completely different from the Uno and A0 and A1 are not digital pins 14 and 15.
Checkout the variants/leonardo/pins_arduino.h definitions.

Hi,

 for(p=0;p<7;p++){
    pinMode(p,OUTPUT);
    }

You are declaring pins 0 to 6 as outputs

Why Pin 0 and Pin 1?
They are used for programming and serial monitor.

See the Tx and Rx on the board, this will cause problems with your serial monitoring.

I want to print a letter whenever an input pin is triggered to a LOW state

Why are you using an output pin to drive an input pin, use a switch and pull-up resistor on your input pin.

Tom..... :slight_smile:

MarkT:
The Leonardo is completely different from the Uno and A0 and A1 are not digital pins 14 and 15.
Checkout the variants/leonardo/pins_arduino.h definitions.

Thank you! :slight_smile: