pin.out inverted?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
demoontz
Posts: 18
Joined: Wed Feb 15, 2017 12:39 pm

pin.out inverted?

Post by demoontz » Sat Apr 08, 2017 8:24 pm

Hello all!
try this code on clean esp8266 with 1.8.7

from machine import Pin
Pin(2, Pin.OUT).high() - led off
Pin(2, Pin.OUT).low() - led on

i guess isn`t right behavior.
or i do smt wrong?
thanx!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: pin.out inverted?

Post by dhylands » Sat Apr 08, 2017 9:34 pm

It depends on how the LED is wired.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: pin.out inverted?

Post by deshipu » Sat Apr 08, 2017 10:24 pm

The LED that is often there on GPIO2 is wired between the pin and the power -- so it's active low, when the pin is connected to the ground and the electricity can flow from the power to the ground.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: pin.out inverted?

Post by pfalcon » Sun Apr 09, 2017 8:48 pm

This is exactly the problem solved by machine.Signal class: https://github.com/micropython/micropyt ... 6_esp12.py
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

demoontz
Posts: 18
Joined: Wed Feb 15, 2017 12:39 pm

Re: pin.out inverted?

Post by demoontz » Mon Apr 10, 2017 7:01 pm

this problem not only with LED pin(gpio2), but with other gpio(12,14) to.
will try inverted=True for all others pins

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: pin.out inverted?

Post by pfalcon » Sat Apr 15, 2017 6:05 pm

It's not a problem, it's a natural situation, and machine.Signal is being introduced to deal with it in a natural way.

It's WIP though, so be ready for changes. For example, it's now invert=True in the latest master.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Post Reply