Due to increasing spam attacks, forum registrations are currently paused to keep our community safe and spam-free. Come hang out and stay connected with us on the SimHub Discord: https://discord.com/invite/nBBMuX7!
Catch you on Discord — and thanks for understanding!
Catch you on Discord — and thanks for understanding!
Notifications
Clear all
Topic starter
14/06/2021 5:16 pm
Hola
Sería genial también si se pudiera añadir joysticks a arduino con 2 ejes.
Topic starter
27/07/2021 8:46 pm
sería algo así.
/* Código de ejemplo Arduino para el módulo Joystick Prototipo del taller www.web-robotica.com Este sketch es de dominio público. */ int xPin = A1; int yPin = A0; int buttonPin = 2; int xPosition = 0; int yPosition = 0; int buttonState = 0; void setup() { // inicializar las comunicaciones en serie a 9600 bps: Serial.begin(9600); pinMode(xPin, INPUT); pinMode(yPin, INPUT); //activar resistencia pull-up en el pin pulsador pinMode(buttonPin, INPUT_PULLUP); // Para las versiones anteriores a 1.0.1 Arduino // pinMode (buttonPin, INPUT); // digitalWrite (buttonPin, HIGH); } void loop() { xPosition = analogRead(xPin); yPosition = analogRead(yPin); buttonState = digitalRead(buttonPin); Serial.print("X: "); Serial.print(xPosition); Serial.print(" | Y: "); Serial.print(yPosition); Serial.print(" | Button: "); Serial.println(buttonState); delay(100); // añadir un poco de retraso entre lecturas }