Hello all,
I'm totaly new to this and i have build a wheel rim for my racing simulator rigg.
I have borrowed an 3x4 script from an button box tutorial, and I'am useing 11 button of the 3x4 matrix.
Problem is that I want to add my 2 paddle-shifter buttons and do this by adding the the buttons that are hocked upp to GND and pin 6 & 7 on my micro arduino card.
Could any one please help me ??
Is it even possible to bake it into the already written code ?
I dont want to open the wheel and rewire things again and was hopping this way may work !
I would be sooo gratefull if some one could help me, a newbi in this project
Best regards Andreas, sorry for my poor english.
Here is my script i use for the other buttons on the wheelplate :
#include <Joystick.h>
// ----------------------------------------------------- Joystick Buttons -------------------------------------------
// -----------------------------------------------------
// Array of pins for the columns
int cPins[] = {3, 4, 5};
// Number of pins in the column array
int cPinsNo = 3;
// Array of pins for the rows
int rPins[] = {A1, A2, A3, A0};
// Number of pins in the row array
int rPinsNo = 4;
// Array for the last known switch states [cPinsNo][rPinsNo]
int colPrev[3][4] = {0};
// Key codes to be used for each button
// (see table above for codes to use)
// (columns and rows are transposed on device)
// [cPinsNo][rPinsNo]
uint8_t buttonCodes[3][4] = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11}
};
void setup()
{
Serial.begin(9600);Â // outputÂ
// Initialize Joystick Library
Joystick.begin();
for(int cPin = 0; cPin < cPinsNo; cPin++){
pinMode(cPins[cPin], OUTPUT);
digitalWrite(cPins[cPin], HIGH);
}
for(int rPin = 0; rPin < rPinsNo; rPin++){
pinMode(rPins[rPin], INPUT);
digitalWrite(rPins[rPin], HIGH);
}
}
void loop() {
// Loop through the columns
for(int cPin = 0; cPin < cPinsNo; cPin++){
digitalWrite(cPins[cPin], LOW);
// Loop through the rows
for(int rPin = 0; rPin < rPinsNo; rPin++){
 // Check if each switch is pressed
 if(digitalRead(rPins[rPin]) == LOW){
  // Check to see if the state has changed since last time
  if(colPrev[cPin][rPin] == 0){
   Joystick.pressButton(buttonCodes[cPin][rPin]);
   // Update last known state of this switch
   colPrev[cPin][rPin] = 1;
  }
 } else {
  // Check to see if the state has changed since last time
  if(colPrev[cPin][rPin] == 1){
   Joystick.releaseButton(buttonCodes[cPin][rPin]);
   // Update last known state of this switch
   colPrev[cPin][rPin] = 0;
  }
 }
}
digitalWrite(cPins[cPin], HIGH);
}
}