Hi,
I use a photo sensor as an object detector and the output of this sensor is an open-collector :

I need to connect this output to a STM32 GPIO input. I also want it connected to a LED directly on the PCB for debugging and test purposes.
I did this on a breadboard and it works :

But basicly I don't understand why, when the open collecter acts as an open switch, you don't have a curent flowing from 3V3 to the MCU and so the LED is lit. What is the current path when the output is off ?
Plus if the the voltage drop of the LED is too high, you migth not be able to detect the High level logic whith GPIO ? I guess the pullup resistor is useless here, maybe internally ?
I also drew this design to invert the output and so the LED is lit when the GPIO reads High level (before it was the opposite) :

(The NPN transistor acts as the output of the sensor and is not in the design)
Is it a good design ? Do you have better/easier solutions (with inverted or not output) ?
I use a photo sensor as an object detector and the output of this sensor is an open-collector :

I need to connect this output to a STM32 GPIO input. I also want it connected to a LED directly on the PCB for debugging and test purposes.
I did this on a breadboard and it works :

But basicly I don't understand why, when the open collecter acts as an open switch, you don't have a curent flowing from 3V3 to the MCU and so the LED is lit. What is the current path when the output is off ?
Plus if the the voltage drop of the LED is too high, you migth not be able to detect the High level logic whith GPIO ? I guess the pullup resistor is useless here, maybe internally ?
I also drew this design to invert the output and so the LED is lit when the GPIO reads High level (before it was the opposite) :

(The NPN transistor acts as the output of the sensor and is not in the design)
Is it a good design ? Do you have better/easier solutions (with inverted or not output) ?