← index #5513Issue #5480
Off-topic · high · value 0.136
QUERY · ISSUE

Pin(16,Pin.OUT) constructor changes state on ESP8266

openby coryallegoryopened 2020-01-10updated 2020-03-03
port-esp8266

Hardware used: Amica NodeMCU v2
Build: esp8266-20191220-v1.12.bin

If the value parameter is not defined when calling the Pin's constructor/init method, the state of the pin peripheral is not supposed to be affected.
http://docs.micropython.org/en/v1.12/library/machine.Pin.html

On my particular test device, there is an LED on gpio 2 and 16. 2 works as expected, however when initializing a Pin instance on gpio16 (on the ESP-12E), its value is changed.

REPL calls to reproduce:

>>> from machine import Pin
>>> led = Pin(16, Pin.OUT, value=0)
>>> print(led.value())
0
>>> led = Pin(16, Pin.OUT)
>>> print(led.value())
1
>>>

I would not expect the value to change to high=1 when no value is set.

CANDIDATE · ISSUE

Serial repl freezes after initializing 16 gpio pins as output in esp32.

closedby gauravgupta45opened 2020-01-01updated 2020-01-01

I am working on a 4x4x4 led cube which uses 20 pins(16+4) as an output.
I am using the following command to initialize 16 pins as output(to use led's on it)

from machine import Pin

column = [0,15,2,4,16,17,5,18,19,21,3,1,22,23,13,12]   #These are the GPIO pins of ESP32
colpin={}
for i in range(0,16):
    colpin[i]=Pin(column[i],Pin.OUT)

After running it in ESP32, my REPL freezes. I'm using Putty for Serial Comm.

But the above piece of code works fine if I decrease the range from 16 to 10.

from machine import Pin

column = [0,15,2,4,16,17,5,18,19,21,3,1,22,23,13,12]
colpin={}
for i in range(0,10):
    colpin[i]=Pin(column[i],Pin.OUT)

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied