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

    Is the Grove port on the M5Stack Basic Core digital or analog?

    General
    3
    5
    4.6k
    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.
    • W
      wwhite
      last edited by

      I'm trying to connect this Seeed Studio button but not having any luck https://www.seeedstudio.com/Grove-Button.html.

      Here is the code:

      #include <M5Stack.h>

      int last_value = 0;
      int cur_value = 0;

      void setup() {
      M5.begin(); // Init M5Stack.
      M5.Power.begin(); // Init power.
      pinMode(21, INPUT); // set pin mode to input.
      M5.Lcd.setTextColor(YELLOW); // Set the font color to yellow.
      M5.Lcd.setTextSize(2); // Setting the Font size.
      M5.Lcd.setCursor(80, 0); // Set the cursor position to (80,0).
      M5.Lcd.println("Button example");
      M5.Lcd.setTextColor(WHITE);
      }

      void loop() {
      cur_value = digitalRead(21); // read the value of BUTTON.
      M5.Lcd.setCursor(80, 25);
      M5.Lcd.print("Button");
      M5.Lcd.setCursor(0, 45);
      M5.Lcd.print("Value: ");
      M5.Lcd.setCursor(0, 85);
      M5.Lcd.print("State: ");
      if (cur_value != last_value) {
      M5.Lcd.fillRect(85, 45, 75, 85, BLACK); // Draw a black rectangle 75 by 85 at (85,45).
      if (cur_value == 0) {
      M5.Lcd.setCursor(95, 45);
      M5.Lcd.print("0"); // display the status
      M5.Lcd.setCursor(95, 85);
      M5.Lcd.print("pre");
      } else {
      M5.Lcd.setCursor(95, 45);
      M5.Lcd.print("1"); // display the status
      M5.Lcd.setCursor(95, 85);
      M5.Lcd.print("rel");
      }
      last_value = cur_value;
      }
      }

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        The Red One?

        Its I2C/ digital

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • W
          wwhite
          last edited by

          Thanks ajb2k3. I have established that I have an I2C device at address 0x53. The device is a Seeed Studio101020054 Grove - 3-Axis Digital Accelerometer. Now how do I read a value from that address?

          Thanks again.

          teastainT 1 Reply Last reply Reply Quote 0
          • teastainT
            teastain @wwhite
            last edited by

            https://github.com/Seeed-Studio/Accelerometer_ADXL345
            This is all you need to get a demo running.
            -You will also have to install these libraries:
            #include <Wire.h>
            #include <ADXL345.h>

            Cheers, Terry!

            100% M5Stack addict with several drawers full of product!

            1 Reply Last reply Reply Quote 1
            • W
              wwhite
              last edited by

              Thanks #teastain that works!

              I simply changed ADXL345 accel(ADXL345_STD) to ADXL345 accel(ADXL345_ALT) in example code ReadXYZ.ino.

              Thanks again.

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