Most tutorials I’ve found so far are about 3-pin photodiodes. These are meant to recieve digital IR signals from TV remotes or similar devices. The 2-pin diodes can be used to simply meassure the available IR light. So you could use this to build a distance sensor, if you add a IR LED emitter and then meassure the reflected light, or to meassure the IR light emitted by a natural or artificial light source. In this article I’ll describe how to use a 2-pin diode on an Arduino and read the IR light value meassured by the diode.


The short side of the diode has to connected to 3.3V and the long side to analog pin A0. We also connect the long side via a 10k ohm resistor to ground.


To read from the diode we simply setup pin A0 to Input so we can read the data via analogRead and output the value to serial.

int irRead;

void setup() {
  pinMode(A0, INPUT);


void loop() {
    irRead = analogRead(A0);