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

    from machine import Pin not working in WiPy 2.0

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0pin
    6 Posts 3 Posters 1.8k 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.
    • C Offline
      ColombianAus
      last edited by seb

      hi there,

      I am trying to execute following code in WiPy 2, and it is throwing and exception.

      >>> from machine import Pin
      >>> p0 = Pin(0, Pin.OUT)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: invalid argument(s) value
      

      trying different ways, always same outcome.

      from machine import Pin
      >>> g = machine.Pin('GP9', mode=Pin.OUT, pull=None, drive=Pin.MED_POWER, alt=-1)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      NameError: name 'machine' is not defined
      

      another way...

      import machine
      >>> p0 = Pin(0,mode=Pin.OUT)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: invalid argument(s) value
      

      I am using Atom, though I did use telnet just in case Atom is playing, still same issue.

      Current version is.

      import os
      os.uname().release
      '1.17.0.b1'

      any advise is apprecaite.

      Cheers
      ColombianBootloader

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @ColombianAus
        last edited by robert-hh

        @colombianaus You tried not all variants. How about that one:

        from machine import Pin
        p0 = Pin("P10", Pin.OUT)
        
        C 1 Reply Last reply Reply Quote 0
        • C Offline
          ColombianAus @robert-hh
          last edited by

          @robert-hh

          hey mate,

          thank you for your advise, it worked!!. so, I am using the pycom extension board, I was wondering if you know what is the pin to pin between WiPy and the extension board. i.e G23 in the extension board is P2 for WyPy 2.0 board.

          Another question, is why on the doco uses GPXX while you use PXX to use Pin class? , XX = a number. Can I use GPXX?

          Cheers
          Colombian

          robert-hhR 1 Reply Last reply Reply Quote 0
          • sebS Offline
            seb
            last edited by

            If you would prefer to use the GXX numbering you can do so like this:

            led = Pin(Pin.exp_board.G16, mode=Pin.OUT)
            

            From: https://docs.pycom.io/chapter/firmwareapi/pycom/machine/Pin.html#class-pinexpboard

            robert-hhR 1 Reply Last reply Reply Quote 1
            • robert-hhR Offline
              robert-hh @ColombianAus
              last edited by

              @colombianaus You can use both numbering variants. The P numbers are those of the development modules, while the GP numbers are those on the expansion board, carried over from the WiPy1 model.

              1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @seb
                last edited by

                @seb Thanks for pointing that out.

                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