Reverse photointerrupter output

I'm currently using a photointerrupt which gives a high voltage when open, and low voltage when it is blocked. I'm using this schematic, with a OPB315 of TT Electronics:

My question is, is there anyway to have the photointerrupt give low voltage when open, and high voltage when blocked?

@yjoeyj
Yes, just swap the positions of the optoisolator and the 10K resistor

Why ?

:thinking:

1 Like

You can also swap it in software; it doesn't cost you anything :wink:

Connect emitter to GND, R1 between the collector and Vcc, and measure collector voltage.

All it needs in your code is an exclamation mark.
sensorValue = digitalRead(sensorPin); // maybe what you have now
sensorValue = !digitalRead(sensorPin); // logic result is the opposite now
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.