Page 1 of 1

machine.Pin(25, Pin.OUT) instead Pin.(25, Pin.OUT) gives error

Posted: Mon Nov 29, 2021 12:58 am
by ht007
Hi.

import machine
machine.ACD(0) .... works properly but
machine.Pin(25, Pin.OUT) ... gives error as Pin is not defined
WHY?

but

from machine import Pin
Pin(25, Pin.OUT) .... works

It's confuses me totally.
Do you have an answer why the error emerges?
Thx in advance.

Re: machine.Pin(25, Pin.OUT) instead Pin.(25, Pin.OUT) gives error

Posted: Mon Nov 29, 2021 6:54 am
by Roberthh
The proper use is:

machine.Pin(25, machine.Pin.OUT)

You imported machine, not Pin. Thus you have to use the full specifier. That's the way Python works.