Set the value of machine.Pin's constructor "value" keyword argument #16432
Unanswered
kresimirhec
asked this question in
ESP32
Replies: 2 comments 5 replies
-
MicroPython v1.24.1 on Generic ESP32 allows me to do: import machine
p=machine.Pin(4, machine.Pin.OUT, value=1) and similarly for Maybe machine.Signal() could help you. It allows you to define a pin with inverted logic |
Beta Was this translation helpful? Give feedback.
3 replies
-
I wonder if the problems result from subclassing |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am having problems invoking machine.Pin's constructor.
I am trying to set the value of "value" keyword argument but it looks like that cannot be done.
Please check the code, it will explain more than I could do with words.
I have commented errors under each base class constructor call.
Here is how the constructor looks like (extracted from machine.pyi):
I could probably create some custom class and try to set this value as it suits me, or devise some hardware NOT gate to reverse the pin signal, but I am wondering:
How can one set this "value" attribute in the constructor, using the Pin class from the library?
Background (irrelevant):
Even though the problem described here is not of hardware nature, here is the story on how I ran into the problem.
Relays I am working with have inverted logic, so I have to set the value to high on start,
I have tried to do a "quick fix" to avoid turning the relay on:
but it was not quick enough: although the relay does not turn on, the corresponding light on relay board does flash for few milliseconds, which does not guarantee that everything will work fine.
Beta Was this translation helpful? Give feedback.
All reactions