Thonny / tiny2040 / pin module failure

209 views
Skip to first unread message

Brian Zimmer

unread,
May 9, 2023, 6:40:09 PM5/9/23
to thonny
Im new to Thonny and am trying to get a script working but there is an issue when i try running it it states:
%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: can't import name pin

I think i need to import pin but where and how do I accomplish this? Following is the very simple script I am trying to run. I do have micropython loaded on the tiny2040 already.

from machine import pin
from time import sleep

ledR = Pin(18,Pin.OUT)
ledG = Pin(19,Pin.OUT)
ledB = Pin(20,Pin.OUT)
ledR.on(); ledG.on(); ledB.on();

while 1:
    sleep(0.5)
    ledR.off(); ledG.on(); ledB.on(); #Red on
    sleep(0.5)
    ledR.on(); ledG.off(); ledB.on(); #Green on
    sleep(0.5)
    ledR.on(); ledG.on(); ledB.off(); #Blue on

I have tried a seperate script and had the same issues with a module called board. 

-Brian-

Kaan Aslan

unread,
May 9, 2023, 6:42:11 PM5/9/23
to Brian Zimmer, thonny
from machine import pin is wrong. pin has to be with capital P.

from machine import Pin

is correct.

Sent with Shift

Brian Zimmer <bfp...@gmail.com>, 10 May 2023 Çar, 01:40 tarihinde şunu yazdı:
> --
> You received this message because you are subscribed to the Google Groups "thonny" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thonny+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/thonny/418e1a99-4055-43ff-a807-f1a592dedb98n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages