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 pinNumber is already a string, you do not need str(pinNumber).
-
@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 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' % pinNumber
or
'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.