Arduino Opto Switch Module from old printer

You can find optical switches on many electronic devices . I found a couple of them when i dissansembled a hp1510 printer.
Next, i will show you how to salvage opto switches from old devices and transform them into opto switch modules for arduino.

An opto switch is composed by two parts : emitter (marked with E) and sensor (marked with S).
The emitter is an infrared led and the sensor is a phototransistor that turns on when hit by a light beam.

After you take apart the opto switch from the device, there are some changes to make in order to transform it into a usable arduino module . The pinout of the optical switch module will be : Signal, Ground, Vcc.

The connections you will have to make are:

Emitter led (marked with E) :

  • The Bottom pin from emiter (usually black wire) is the ground.
  • The upper pin (usually red wire) is vcc and should be connected through a 220 ohm resistor to arduino VCC.

Sensor (marked with S) :

  • The upper pin (usualy green wire) from sensor is ground and it is connected to ground toghether with the black wire of the emitter.
  • The bottom pin (may be a white wire) from sensor, is positive and should be connected to +5v through a 10k resistor and to arduino digital pin 3.

After soldering all the componets toghether,  the next step is to test the optical switch module. We will receive feedback from module in two ways: output sent to the Serial Monitor, and blinking a led.

  • connect the long leg of the led to arduino D7 through a 270 ohm resistor
  • connect the short leg of the led to ground
  • connect the signal pin of the opto switch module to the arduino D3
  • connect the Vcc pin of the module to arduino VCC
  • connect the ground pin of the module to arduino ground

The digital pin 3 on arduino will be low when is no obstacle between emitter and sensor and high when the light is blocked.

After you made the connections between arduino and the opto switch module, upload the following schetch to arduino using Arduino Studio.
Open the Serial Monitor from Arduino Studio and set the baud rate to 9600 baud.
You cant test the opto switch module by passing an obstacle between emitter and sensor.

const int LED_PIN = 7;

void setup()
  pinMode(LED_PIN, OUTPUT);

void loop()
  if  (digitalRead(OPTOSWITCH_PIN) == 0)  
    // There is no obstacle between emitter and sensor
    digitalWrite(LED_PIN, HIGH);
    digitalWrite(LED_PIN, LOW);


Leave a Reply

Your email address will not be published. Required fields are marked *