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

    Adding a switch to the DinMeter

    Scheduled Pinned Locked Moved Units
    3 Posts 1 Posters 382 Views
    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.
    • C Offline
      cdnstig
      last edited by

      I am trying to add an external switch to the DinMeter, but am having trouble reading the stitch closure. If I prototype this on an Arduino Uno, I have no issues and it works as expected. Is there a chance that I'm not calling the proper pin? I am trying to use G1 on PortB as I suspect that is the proper one. Or is there a chance that I can't do a digitalRead on that pin for the switch to work?

      int switchPin = G1;
      int switchValue = 0;

      void setup() {
      pinMode(switchPin, INPUT_PULLUP);
      }

      void loop() {
      if (switchValue = digitalRead(switchPin) == LOW) {
      do something...
      }
      }

      Thanks.

      C 2 Replies Last reply Reply Quote 0
      • C Offline
        cdnstig @cdnstig
        last edited by

        In case anyone else comes across this post, it appears that the wires coming out of the DinMeter PortB are reversed to the label, at least on my unit. G1 is the yellow wire, and G2 is the white one. It works as expected to do a digital read on the pins for a button push.

        1 Reply Last reply Reply Quote 0
        • C Offline
          cdnstig @cdnstig
          last edited by

          In case anyone else comes across this post, it appears that the wires coming out of the DinMeter PortB are reversed to the label, at least on my unit. G1 is the yellow wire, and G2 is the white one. It works as expected to do a digital read on the pins for a button push.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post