Moin,
ich habe einen XY-Joystick an einem ESP32 angeschlossen und versuche einen Punkt auf einer 32x32 MAX7219 Matrix damit zu steuern.
Funktionieren tut das.
Die Joysticksteuerung kenne ich aus dem RC Bereich (Hubschrauber) sehr gut.
Wenn man den Stick bewegt, dann bewegt sich ein Servo proportional dazu. Wenn man beide Endwerte und den Mittelpunkt korrekt eingestellt hat, dann folgt das Servo ebenso korrekt der Position des Sticks.
So, nun übertragen in die Arduino Welt wäre ich vom gleichen Verhalten ausgegangen, d.h. die analogen Einlesewerte stehen in einem proportionalen Verhältnis zur Position des Sticks.
Auch das funktioniert grundsätzlich.
Aber: Das Steuergefühl ist sowas von unstetig und schlecht.
Ich könnte mir vorstellen, dass dies an extremst schlechten/billigen Potis liegt.
Hat jemand ähnliche Erfahrungen gemacht?
Hat jemand einen Tipp zu qualitativ guten Joysticks, die auch eine proportionale Steuerung zulassen?
Hat jemand einen Tipp wie man das pragmatisch testen könnte?
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 5; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 4;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
int x = 0;
int y = 0;
void setup() {
Serial.begin(115200);
matrix.setIntensity(0); // Set brightness between 0 and 15
matrix.setPosition(0, 3, 3); // The first display is at <0, 0>
matrix.setPosition(1, 2, 3); // The second display is at <1, 0>
matrix.setPosition(2, 1, 3); // The third display is at <2, 0>
matrix.setPosition(3, 0, 3); // And the last display is at <3, 0>
matrix.setPosition(4, 0, 2); // The first display is at <0, 0>
matrix.setPosition(5, 1, 2); // The second display is at <1, 0>
matrix.setPosition(6, 2, 2); // The third display is at <2, 0>
matrix.setPosition(7, 3, 2); // And the last display is at <3, 0>
matrix.setPosition(8, 3, 1); // The first display is at <0, 0>
matrix.setPosition(9, 2, 1); // The second display is at <1, 0>
matrix.setPosition(10, 1, 1); // The third display is at <2, 0>
matrix.setPosition(11, 0, 1); // And the last display is at <3, 0>
matrix.setPosition(12, 0, 0); // The first display is at <0, 0>
matrix.setPosition(13, 1, 0); // The second display is at <1, 0>
matrix.setPosition(14, 2, 0); // The third display is at <2, 0>
matrix.setPosition(15, 3, 0); // And the last display is at <3, 0>
matrix.setRotation(0, 1); // The first display is position upside down
matrix.setRotation(1, 1); // The first display is position upside down
matrix.setRotation(2, 1); // The first display is position upside down
matrix.setRotation(3, 1); // The same hold for the last display
matrix.setRotation(4, 3); // The first display is position upside down
matrix.setRotation(5, 3); // The first display is position upside down
matrix.setRotation(6, 3); // The first display is position upside down
matrix.setRotation(7, 3); // The same hold for the last display
matrix.setRotation(8, 1); // The first display is position upside down
matrix.setRotation(9, 1); // The first display is position upside down
matrix.setRotation(10, 1); // The first display is position upside down
matrix.setRotation(11, 1); // The same hold for the last display
matrix.setRotation(12, 3); // The first display is position upside down
matrix.setRotation(13, 3); // The first display is position upside down
matrix.setRotation(14, 3); // The first display is position upside down
matrix.setRotation(15, 3); // The same hold for the last display
}
void loop() {
Serial.print("x: ");
Serial.print(analogRead(34));
Serial.print(" ");
Serial.print(map(analogRead(34), 0, 4095, 0, 32));
Serial.print(" y:");
Serial.print(analogRead(35));
Serial.print(" ");
Serial.println(map(analogRead(35), 0, 4095, 0, 32));
matrix.drawPixel(map(analogRead(34), 0, 4095, 0, 32), map(analogRead(35), 0, 4095, 0, 32), HIGH);
matrix.write();
delay(10);
}
Lieben Gruß,
Chris