December 15, 2024
Description
Buttonbox für Länkräder fürs Sim Racing
Benötigte Teile
1x Arduino Micro Pro
12x Buttons ( hole D12)
7x M3 20mm screw
2x M3 30mm screw
2x M3 nut
15x M3 heat inserts
2x OMRON D2HW-BL201H
4x 10x5mm magnets
Viel Erfolg beim Bau deiner Buttonbox! 😊
Arduino code :
#include <Joystick.h>
// Anzahl der Buttons definieren
#define NUM_BUTTONS 16
// Pins der Buttons
int buttonPins[NUM_BUTTONS] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 17, 18, 19, 20};
// Joystick-Instanz erstellen
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_GAMEPAD,
NUM_BUTTONS, // Anzahl Buttons
0, // Keine Achsen
false, false, false, // Keine X, Y, Z Achse
false, false, false, // Keine RX, RY, RZ Achse
false, false, // Keine Rudder, Throttle
false, false, false); // Keine Accelerator, Brake, Steering
void setup() {
// Buttons als Eingang konfigurieren
for (int i = 0; i < NUM_BUTTONS; i++) {
pinMode(buttonPins[i], INPUT_PULLUP); // Pull-Up-Widerstand aktivieren
}
// Joystick starten
Joystick.begin();
}
void loop() {
// Status der Buttons auslesen und an Joystick melden
for (int i = 0; i < NUM_BUTTONS; i++) {
int buttonState = digitalRead(buttonPins[i]);
// LOW bedeutet gedrückt, da Pull-Up-Widerstand aktiv ist
Joystick.setButton(i, buttonState == LOW ? 1 : 0);
}
delay(10); // Polling-Intervall
}
License:
Standard Digital File License