LED as both photo-detector and emitter

A. Background

LED is now widely used in our life to provide various illumination.  You can buy LED components and related products from eBay with very low cost.  However, since it is so popular as a light source, we almost forget that LED is essentially a photodiode, that is, it can respond to light.  Depending on the emitting wavelength of the LED, when the LED is stricken by photons with similar or shorter wavelengths, a tiny photo-current will be generated.  If we can measure this photo-current, we can then measure the photons striking on the LED.  Therefore, LED can be used both as a light emitter and as a light detector.  This allows us to realize low-cost two-way communication with a single LED.

For details of this please refer to Paul Dietz’s white paper “Very Low-Cost Sensing and Communication Using Bidirectional LEDs”  (http://www.merl.com/publications/docs/TR2003-35.pdf).


In this post, we will use an Arduino Nano board and a single LED to demonstrate this idea.


B. Materials

  1. Arduino Nano board x 1
  2. Breadboard x 1
  3. Red LED x 1
  4. 150 Ohm resistor x 1
  5. USB cable (A plug to mini-B plug) x 1
  6. Jumper wires
  7. Flashlight x 1


C. Key Notes

The LED is set to work in three modes: 1. Emitting; 2. Charging (reverse bias); 3. Discharging. By cycling the three different modes, the same LED can be used to realize two-way communication by detecting and emitting light.

LED bi-directional


In the reverse-bias mode and the discharging mode, an LED can be modeled as a capacitor connected with a current source in parallel, as shown below:

LED reverse-biasing


The charging or discharging constant of the LED is related to the value of the photo-current excited by the light striking on the LED.  When the light is strong, the photo-current is high, and thus the discharging process is quick.  When the light is weak, the discharging process is relative slow.

Arduino Nano board can easily cycle through all the three modes of an LED.  Only two pins of the Nano board is needed, one is a digital pin, and the other is an analog pin.  The digital pin is connected to the anode of the LED.  The analog pin is connected to the cathode of the LED through a current limiting resistor.  The analog pin can be used to detect electric signal charged on the LED, and also be used as a digital pin to set the digital level of LED cathode to provide reverse bias or light emitting.


D. Diagram

LED sensor diagram


E. Arduino Sketch

LED Bi-directional Communication

This sketch demonstrates that LED can be used both as
photo emitter and as photo detector, and thus a single
LED can be used to realize two-way communication

Open Source Photonics


int ledA = 6;
int sensorPin = A5;
int sensorValue;
int interval = 100;  // ms
int counter = 0;
int mode = 0;   // 0 for normal mode, 1 for alarm mode
int threshold = 400;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(ledA, OUTPUT);
  pinMode(sensorPin, OUTPUT);

// the loop routine runs over and over again forever:
void loop() {
  if (mode == 0 && counter%10 != 0) {  // no emitting
    digitalWrite(ledA, LOW);
    digitalWrite(sensorPin, LOW);
  else {
    digitalWrite(ledA, HIGH);  // emitting
    digitalWrite(sensorPin, LOW);

  digitalWrite(ledA, LOW);  // charging
  digitalWrite(sensorPin, HIGH);

  pinMode(sensorPin, INPUT);  // discharging
  sensorValue = analogRead(sensorPin);  // value after certain time
  Serial.print("value: ");

  if (sensorValue < threshold) mode = 0;  // quick discharging
  else mode = 1;      // slow discharging

  pinMode(sensorPin, OUTPUT);
  counter = counter+1;




F. Result and discussion

After connecting all the components on a breadboard, we can get a setup as shown below:

led sensor setup

When we finished the setup, just load the Arduino sketch into the Nano board, and keep the USB cable connected.  When the LED is illuminated by a flashlight or other light sources, the LED flashes once every 2 seconds.  However, when the light striking the LED is blocked, the LED flashes quickly at a frequency of about 5 Hz.

This setup is mainly used to demonstrate the two-way communication with a single LED, but you can use it for other purposes, too.  For example, it can be used to detect an obstacle between the light source and the LED, just like a tripwire.  As a demo, we use a simple flashlight as the illumination source, and the flashlight can be put 2 feet away and still make the system work.  In a future work we will use a laser pointer and an LED to build a real tripwire in the garage.  Hint: the wavelength of the laser should be similar or shorter than that of the LED.



All the materials needed for this project can be purchased from eBay.


Thanks for reading.  Open Source Photonics Blogs are supported by 612 Photonics.


Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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

%d bloggers like this: