I do apologise for not posting the code correctly, I am not experience in using much of the arduino range a specially code part, most of my projects is from video and try and error, this code has been used for something else and it works for me from Pin 0 - 13, now this give me 14 digital inputs, for my new project I have spare leonardo board in drawer so wanted to utilize this but need 19 inputs, I know is possible to use the A0-A5 analog pins to use it as digital input for switches ect. (toggle/rotary), maybe a bit cheeky of me asking what I should and where write it to have this working but if I don't ask I won't know
as for wiring there isn't much, lets say there will be 19 toggle switches, on/off nothing fancy, I know there are other boards that would be lot easier for me to use but this is just laying around so with your help if I can get this working would be great.
Also only using 1 switch to try the individual pins, one at the time
#include <Joystick.h>
Joystick_ Joystick;
int led = 13;
void setup() {
// Initialize Button Pins
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
// Constant that maps the physical pin to the joystick button.
const int pinToButtonMap = 0;
// Last state of the button
int lastButtonState[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void loop() {
// Read pin values
for (int index = 0; index < 14; index++)
{
int currentButtonState = !digitalRead(index + pinToButtonMap);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
delay(50);
}