Moin.
Ich habe vor einigen Tagen meine Alps von Aliexpress erhalten und habe mich mal an ihnen versucht. Außerdem habe ich noch ein Gehäuse entworfen, welches für eigene Projekte verwendet werden kann. Die Inspiration hatte ich von Peters OMP-
Lenkrad, danke dafür.
This is a mount for the 7-way funky switch (ALPS RKJXT1F42001). You can use it for your projects and add it in to your stl. It is a tight fit for me so maybe you have to scale it a little bit. I added a "lock" to prevent movement on the button when the push button is pressed. The Knob is taken...
www.thingiverse.com
Anhang anzeigen 91802
Anhang anzeigen 91801
Ich habe echt Mühe gehabt, die richtige PIN-Belegung aus den Grafiken herauszulesen, weswegen ich dann alle Pole mit dem Multimeter getestet habe und somit die Belegung herausgefunden habe.
Anhang anzeigen 91809
Ich habe einen einfachen Sketch geschrieben, der die einzelnen Funktionen prüft. Außerdem konnte ich das Problem lösen, dass beim Drücken in eine Richtung auch der Pushbutton ausgelöst wird.
Mit meinem Sketch kann ich nun folgendes tun:
- Pushbutton drücken und auch in jede Richtung bewegen, es wird nur der Pushbutton getriggert
- Richtungstasten drücken ohne dabei den Pushbutton auszulösen
- Encoder wie gewünscht nutzen
Somit kann ich alle 7 Funktionen des Switches einzeln aktivieren, ohne mehrere Buttons auf einmal zu drücken. Testen sehr gerne erwünscht, ich meine es funktioniert alles wie gewollt. Das ganze läuft derzeit auf einem Arduino Uno ohne Joysticklibrary, sollte jedoch problemlos auf den Pro Micro übertragbar sein.
Zur Demonstration habe ich noch ein Video bei Youtube hochgeladen um das ganze zu verdeutlichen:
Hier noch der Sketch:
C:
// Rotary Encoder Inputs
#define inputCLK 4
#define inputDT 5
int counter = 0;
int currentStateCLK;
int previousStateCLK;
const int pushPin = 12;
const int upPin = 11;
const int downPin = 10;
const int leftPin = 8;
const int rightPin = 9;
int pushState = 0;
int upState = 0;
int downState = 0;
int leftState = 0;
int rightState = 0;
String encdir = "";
int timer = 0;
void setup() {
pinMode (inputCLK, INPUT_PULLUP);
pinMode (inputDT, INPUT_PULLUP);
pinMode(pushPin, INPUT_PULLUP);
pinMode(upPin, INPUT_PULLUP);
pinMode(downPin, INPUT_PULLUP);
pinMode(leftPin, INPUT_PULLUP);
pinMode(rightPin, INPUT_PULLUP);
previousStateCLK = digitalRead(inputCLK);
Serial.begin(9600);
}
void loop() {
pushState = digitalRead(pushPin);
upState = digitalRead(upPin);
downState = digitalRead(downPin);
leftState = digitalRead(leftPin);
rightState = digitalRead(rightPin);
currentStateCLK = digitalRead(inputCLK);
if (pushState == LOW) {
if (timer >= 5) {
Serial.println("push");
} else {
if (upState == LOW) {
Serial.println("up");
timer = 0;
} else if (downState == LOW) {
Serial.println("down");
timer = 0;
} else if (leftState == LOW) {
Serial.println("left");
timer = 0;
} else if (rightState == LOW) {
Serial.println("right");
timer = 0;
} else {
Serial.println("push");
Serial.println(timer);
timer++;
}
}
} else {
timer = 0;
}
// If the previous and the current state of the inputCLK are different then a pulse has occured
if (currentStateCLK != previousStateCLK) {
// If the inputDT state is different than the inputCLK state then
// the encoder is rotating ccounterclockwise
if (digitalRead(inputDT) != currentStateCLK) {
counter --;
encdir = "CCW";
} else {
// Encoder is rotating clockwise
counter ++;
encdir = "CW";
}
Serial.print("Direction: ");
Serial.print(encdir);
Serial.print(" -- Value: ");
Serial.println(counter);
}
// Update previousStateCLK with the current state
previousStateCLK = currentStateCLK;
delay(1);
}
Beste Grüße und ich hoffe, dass ich nichts übersehen habe

Michael