🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5StickC Plus and Joystick HAT Problem

    Modules
    2
    2
    2.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      Volos
      last edited by

      Hello! I have problem with Joystick Hat , this one "https://m5stack.com/collections/m5-hat/products/m5stickc-joystick-hat"
      Its working on my M5StickC but i can't make it work on M5StickC Plus. Here is my code:

      #include <M5StickCPlus.h>
      #include "Wire.h"

      #define JOY_ADDR 0x38

      void setup() {
      M5.Lcd.begin();
      //M5.Lcd.clear();
      //disable the speak noise
      //dacWrite(25, 0);
      Wire.begin(0,26);

      M5.Lcd.setRotation(1);
      M5.Lcd.drawString("bok",0,0,2);
      }

      uint8_t x_data;
      uint8_t y_data;
      uint8_t button_data;
      char data[100];
      void loop() {
      // put your main code here, to run repeatedly:
      Wire.requestFrom(JOY_ADDR,3);
      if (Wire.available()) {
      x_data = Wire.read();
      y_data = Wire.read();
      button_data = Wire.read();
      sprintf(data, "x:%d y:%d button:%d\n", x_data, y_data, button_data);

      M5.Lcd.setCursor(1, 30, 2);
      M5.Lcd.printf("x:%04d y:%04d button:%d\n", x_data, y_data, button_data);
      

      }
      delay(200);
      }

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @Volos

        have you tried the official Joystick hat example?

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • First post
          Last post