Buongiorno devo riuscire a far riconoscere la mia arduino leonardo che ho comprato apposta per le sue caratteristiche come joypad. Avevo provato con questo codice ma il gioco non funziona sempre
/*
ABP (Arduino Beatmania Project)
Source Code
*/
const int buttonPin1 = 3;
const int buttonPin2 = 4;
const int buttonPin3 = 5;
const int buttonPin4 = 6;
const int buttonPin5 = 7;
const int buttonPin6 = 8;
const int buttonPin7 = 9;
int previousButtonState1 = HIGH;
int previousButtonState2 = HIGH;
int previousButtonState3 = HIGH;
int previousButtonState4 = HIGH;
int previousButtonState5 = HIGH;
int previousButtonState6 = HIGH;
int previousButtonState7 = HIGH;
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
pinMode(buttonPin6, INPUT);
pinMode(buttonPin7, INPUT);
Keyboard.begin();
}
void loop() {
int buttonState1 = digitalRead(buttonPin1);
int buttonState2 = digitalRead(buttonPin2);
int buttonState3 = digitalRead(buttonPin3);
int buttonState4 = digitalRead(buttonPin4);
int buttonState5 = digitalRead(buttonPin5);
int buttonState6 = digitalRead(buttonPin6);
int buttonState7 = digitalRead(buttonPin7);
if ((buttonState1 != previousButtonState1)
&& (buttonState1 == HIGH)) {
Keyboard.print("a");
}
if ((buttonState2 != previousButtonState2)
&& (buttonState2 == HIGH)) {
Keyboard.print("b");
}
if ((buttonState3 != previousButtonState3)
&& (buttonState3 == HIGH)) {
Keyboard.print("c");
}
if ((buttonState4 != previousButtonState4)
&& (buttonState4 == HIGH)) {
Keyboard.print("d");
}
if ((buttonState5 != previousButtonState5)
&& (buttonState5 == HIGH)) {
Keyboard.print("e");
}
if ((buttonState6 != previousButtonState6)
&& (buttonState6 == HIGH)) {
Keyboard.print("f");
}
if ((buttonState7 != previousButtonState7)
&& (buttonState7 == HIGH)) {
Keyboard.print("g");
}
previousButtonState1 = buttonState1;
previousButtonState2 = buttonState2;
previousButtonState3 = buttonState3;
previousButtonState4 = buttonState4;
previousButtonState5 = buttonState5;
previousButtonState6 = buttonState6;
previousButtonState7 = buttonState7;
delay(20);
}
Avete qualche soluzione? Grazie