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

    Setting Pin to High

    Scheduled Pinned Locked Moved WiPy 2&3
    4 Posts 2 Posters 1.4k Views 2 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.
    • K Offline
      Knoahlr
      last edited by

      I`m having trouble setting pins to High, for output.
      Is this the right way to do it?

      Tpin=Pin.init(Pin.OUT)
      Tpin.value(1)

      1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino
        last edited by jmarcelino

        You need to specify which pin it is. Check the pinout post to find the pin label for the one you want.

        Here's an example for pin P23.

        from machine import Pin
        tpin=Pin('P23',Pin.OUT)
        tpin.value(1) 
        
        K 1 Reply Last reply Reply Quote 0
        • K Offline
          Knoahlr @jmarcelino
          last edited by

          @jmarcelino Hey, I did that, just forgot to put it in the post.
          if you do
          .....

          from machine import Pin
          tpin=Pin('P23',Pin.OUT)
          tpin.value(1)
          print(tpin.value())

          Do you get 1 ?

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jmarcelino @Knoahlr
            last edited by jmarcelino

            @Knoahlr
            I don't have my WiPy nearby to test but note that for pins set as Pin.OUT the behaviour and return value of the value() is undefined, you can't really trust it will match what you sent.

            See https://micropython.org/resources/docs/en/latest/wipy/library/machine.Pin.html

            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