is there a way to check an output pin HIGH or LOW ?
-
when i turn on or set high to an output pin in LOPY4, is there a way to confirm it sets to HIGH or LOW without physically check the pin ?
I turn on pin high by using these 2 lines of code:
pin = Pin(str(pinNumber), mode=Pin.OUT) pin.value(1) -
@soibac35 If pinNumer is a number, then str(pinNumber) does not result in a valid pin name. Instead you should get an error message:
ValueError: invalid argument(s) value
You could use something like;
'P%d' % pinNumberor
'P' + str(pinNumber)
But about your question: you can always read back the Pin's state with pin.value(), even when set to OUT mode. -
@robert-hh Perfect. That's all i need to know. Thank you.
For pinNumber thou, i will have something like
def turnOFF(pinNumber): pin = Pin(str(pinNumber), mode=Pin.OUT) pin.value(0)where I input pinNumber as P23 or P24...
-
@soibac35 if pinNumber is already a string, you do not need str(pinNumber).
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login