from machine import Pin not working in WiPy 2.0
ColombianAus last edited by seb
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
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.
any advise is apprecaite.
@seb Thanks for pointing that out.
@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.
seb last edited by
If you would prefer to use the
GXXnumbering you can do so like this:
led = Pin(Pin.exp_board.G16, mode=Pin.OUT)
ColombianAus last edited by
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?
@colombianaus You tried not all variants. How about that one:
from machine import Pin p0 = Pin("P10", Pin.OUT)