Pin logic inverted on LOLIN D1 mini v4.0.0 #16935
-
I have a LOLIN D1 mini v4.0.0 I flashed from machine import Pin
p = Pin(2, Pin.OUT)
p.on()
p.off() The problem is that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The names of p.on() and p.off() are misleading. A pin cannot be on of off. And whether a LED connected to a pin turns on or off depends on it's wiring. p.on() sets the pin output high, to about 3.3V. p.off() sets it low. If the LED is connected between Vcc and the Pin, it will light up with p.off() |
Beta Was this translation helpful? Give feedback.
The names of p.on() and p.off() are misleading. A pin cannot be on of off. And whether a LED connected to a pin turns on or off depends on it's wiring. p.on() sets the pin output high, to about 3.3V. p.off() sets it low. If the LED is connected between Vcc and the Pin, it will light up with p.off()
For driving a LED better use the machine.Signal class. It has the option to set the logic to invert. Then signal.on() will turn the LED on. See https://docs.micropython.org/en/latest/library/machine.Signal.html#machine.Signal