from machine import Pin not working in WiPy 2.0
-
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) valuetrying 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 definedanother way...
import machine >>> p0 = Pin(0,mode=Pin.OUT) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid argument(s) valueI 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 -
@colombianaus You tried not all variants. How about that one:
from machine import Pin p0 = Pin("P10", Pin.OUT) -
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 -
If you would prefer to use the
GXXnumbering 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
-
@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 Thanks for pointing that out.
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