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

    [Solved]How to use the angle sensor?

    Units
    4
    24
    79.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.
    • ajb2k3A
      ajb2k3 @lukasmaximus
      last edited by

      @lukasmaximus 在 How to use the angle sensor? 中说:

      I can get a readout from the angle sensor on both the serial console and lcd with this sketch. Try it out and see if it works for you. I'm using the m5go but the pinout should be the same. Make sure you connect the black wire to gnd, the red wire to 5v and the white wire to 36

      <code>

      #include <M5Stack.h>

      void setup()
      {
      M5.begin();
      M5.Lcd.setBrightness(30);
      M5.Lcd.clear();

      }

      void loop()
      {
      M5.Lcd.setCursor(160, 120);
      int adc = analogRead(36);
      M5.Lcd.println(adc);
      Serial.println(adc);
      delay(2);
      }
      </code>

      My self and Ken are using the grove port which is pin 22&23 and so can't move it over to a different port.
      @ken57093 - I haven't forgotten about you my friend, I just been busy trying to finish some of my backlog of projects which the M5Stack is proving to be very usefull for.

      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!

      K 1 Reply Last reply Reply Quote 0
      • K
        ken57093 @ajb2k3
        last edited by ken57093

        @ajb2k3
        Haha, it's fine. I almost give up trying the angle sensor myself. Now I'm trying to use the SIM800L GSM module.

        1 Reply Last reply Reply Quote 0
        • lukasmaximusL
          lukasmaximus
          last edited by

          My apologies guys, I presumed you were using the m5go or fire as I am. If you are using the gray or black core models you will need to use jumper cables to attach the angle sensor to the pins on the bottom of the core as shown in this picture. it is not possible to connect the angle sensor to 22 or 23 as they are digital inputs, for the angle sensor we need an analog input or ADC (analog to digital converter) pin, so this is only possible on pins 35 and 36. try to connect as I show in these pictures and try again, it should display the numbers on both the serial monitor and the screen.![](http://imagehosting.biz/image/6ut
          http://imagehosting.biz/image/6u0)

          K 1 Reply Last reply Reply Quote 1
          • K
            ken57093 @lukasmaximus
            last edited by

            @lukasmaximus

            Thank you. I will try it again after buying the wire

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