Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    user button configuration

    Scheduled Pinned Locked Moved LoPy
    user button
    4 Posts 3 Posters 1.7k Views 3 Watching
    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.
    • A Offline
      assia
      last edited by

      I want to print a msg when i press a user button on the pycom board,
      but i get about 92 msgs when i press the button only once !

      import machine
      
      button=machine.Pin("G17",  machine.Pin.IN,  machine.Pin.PULL_UP)
      
      while(True):
          if(button.value()==0):
              print("presssss !!!!")
      

      How can i configure the button so that when i press once only i get a single output(msg)

      thanks

      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @assia
        last edited by

        @assia
        look here
        https://forum.pycom.io/topic/588/interrupt-button-debounce-with-long-short-press

        think about people first, then computers

        1 Reply Last reply Reply Quote 0
        • RobTuDelftR Offline
          RobTuDelft
          last edited by

          Quick solution is to use pull_up resistor like you did and create empty while loop when value is 0.
          Then after releasing the button add a small delay, ~100 ms will do. Then add futher statements after the delay.

          Without data you're just another person with an opinion.
          Hackster | About me

          A 1 Reply Last reply Reply Quote 0
          • A Offline
            assia @RobTuDelft
            last edited by

            thanks @RobTuDelft It worked well

            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
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom