I'm trying to wire a button matrix for a PC Controller to increase the number of buttons from 12 to 16.
The tutorial I started said to use digital pins for the columns, and analog pins for the rows, do I absolutely need to use analog pins, or can I use all digital pins? I need the analogs open for 2 joysticks.
I'm using an Arduino Pro Micro (4 analog pins, 12 digital pins), I want to make a 4x4 matrix
Looking at the JoystickButton example from the library it does not use a button matrix, rather the sketch just polls 4 digital pins to test their input state
for (int index = 0; index < 4; index++)
{
int currentButtonState = !digitalRead(index + pinToButtonMap);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
The library setButton() function sets the state of a pin number passed to it
Of course. It only uses "analog" pins because in the ATmega processors they in fact are digital pins which just happen to have additional analog capability if - and only if - it is required.