Making endstops from printer photo interrupters.

If you have pulled apart a printer, fax or scanner then there is a high likelihood that you have found a few photo interrupters.

A collection of photo interrupters

Some of these may be pre-packaged in a plastic housing with three wires attached which you can modify to use as endstopsuitable for reprap/repstrap.

The most common three wire photo interrupters you will find consist of a infrared (IR) LED and a photo transistor packaged facing each other. When in use the IR LED is always on and exposed to the photo transistor allowing a current to flow. When the IR LED is blocked it will stop the flow of current through the photo transistor and this change is detected by a .

The IR LED is on the left and the photo transistor on the right.

To use a photo interrupter with your reprap you will need to identify the three wires leaving the photo interrupter. The are Vcc, Gnd and signal. Vcc is connected to the IR LED anode (+) , signal is connected to the photo transistor collector (+) and ground is connected to both the IR LED cathode and the photo transistor emitter.

If the photo interrupter is mounted on a PCB then it should be fairly straight forward to identify which wire is which by following the traces and any markings.

IR LED on the right and the photo transistor in the left. K for Cathode.

However if its mounted to a plastic base then you will need to pop off the shroud (the black plastic in the image below) and by using your multimeter identify which wire is connected to one of the legs for both the IR LED and also to the photo diode. This is the Gnd. Then identify which wire is connected to the other leg (non Gnd) of the photo diode, this is the signal. The photo diode is normally tinted or black. The last remaining wire is Vcc to the LED anode.

Once each wire is labelled its time to construct a small circuit from stripboard so that the photo interrupter can be interfaced with your reprap host electronics. Construct the circuit seen below.

Once finished it might look similar to the setup below. The PCB above the strip board is the standard endstop PCB used by a Mendel.

You can test it with the sketch below that was taken from the reprap wiki and modified a little.

#define ENDSTOP_PIN 2  //what pin are we using?

void setup()

Serial.println(“Starting opto endstop exerciser.”);

void loop()
if (digitalRead(ENDSTOP_PIN))
if (0)


Other useful links include here and here. If you see a mistake above please let me know.

About Richard

I am a Materials Engineering working in the field of Magnetic Materials in Melbourne, Australia. This blog covers my personal interest in all things CNC.
This entry was posted in Mendel Build and tagged , , , , , , . Bookmark the permalink.

8 Responses to Making endstops from printer photo interrupters.

  1. nophead says:

    The 10K should be a pull up, not a pull down, and I wouldn’t make it bigger than 10K.

    The way you have it wired in the diagram will make the LED glow dimly when it should be off and the logic ‘1’ level at the arduino will be marginal.

    • Richard says:

      Thanks, this is all still relatively new to me. Using a 100k pull down resistor resulted in so little current draw that I couldnt tell if it was on or not.

      So the correct way of doing it would look like this?:
      Take two.

  2. nophead says:

    Yes that is correct. The pullup ensures the line goes to 5V, giving best noise immunity.

  3. DavidBuzz says:

    Arduino Pins have built-in pullup resistors, so it’s just a case of enabling the pullup/s on the appropriate pins, and you can leave that resistor out entirely.
    pinMode(pin, INPUT); // set pin to input
    digitalWrite(pin, HIGH); // turn on pullup resistors
    for more.

    Infact, 4 days ago, I added support to the firmware ( in SVN) for precisely this:

    ( who happens to be using printer optos too).
    Mine are all conveniently labeled on the back of the plug/opto pcb with “GOV” ( Gnd, Output, VCC ), so the 3 pins are obvious. 🙂

  4. nophead says:

    Yes they are only 20K though, so a bit on the high side. When you use the 4 pin optos the value actually sets the gain of the photo transistor, so affects the sensitivity. Hard to say what the ideal value is without the datasheet for the opto.

  5. Jan says:

    Hi, I used your idea but as a pcb I used an switch type endswitch (mech endstop v1.2) and removed the micro switch. This give’s you a pcb with connector, led, pullup etc. You can use the three solderplaces of the switch to connect the wires to the opto board, only the 150R must be added somewhere. It can in schrink tube in the plus wire. NO= Gnd, NC=VCC, COM=Output (the collector of the phototransistor in your drawing). If you like I, can send you a picture.

    Grtz Jan The Netherlands

  6. Chris says:

    My opto switches are labeled with “A” “G” “C” and per the above diagram I take it to mean A=anode, G=ground, and C=collector with Anode going to positive, ground going to negative and collector going to signal on my Arduino. Sound right?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s