I/O LED (Part 1)

Part 123456

I was strugling after parasitic capacitance of photodiodes, when I came accross the awsome paper:
“Very Low-Cost Sensing and Communication Using Bidirectional LEDs” witten by Paul Dietz, William Yerazunis, Darren Leigh from the MITSUBISHI ELECTRIC RESEARCH LABORATORIES http://www.merl.com

This paper puts the emphasis on the use of LED for emitting coded pulses as well as for receiving these sorts of pulses. How come???

Simple and bright as a LED. Alike photodiodes, LED’s equivalent circuit comprises a capacitor. When the diode is properly oriented (photovoltaic mode) and properly biased (reversed mode), the internal capacitor will charge proportionnally to the number of received photons hitting the depletion region of the chip.

Note: Some tests performed on a dozen of various LEDs from my shelves show a great variety of capacitance. The application below may even not work at all because of the very low capacitance of some diodes.

Once you are aware (or reminded) about this proprerty, the rest is simple. All you have to do properly set the ports from your Arduino board. Starting from this point, it is possible to envisage many applications, including cheap communication devices. Firstly, the following application will allow you to select the LED which work!

Here is the hardware (Simple isn’t it!)

And here is the code


	LEDCapacitance as per:
	Very Low-Cost Sensing and Communication	Using Bidirectional LEDs
	by Paul Dietz, William Yerazunis, Darren Leigh
	TR2003-35 July 2003	

	ATmega328 powered Arduinos only
	Copyright (C) 2011 Didier Longueville

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.


#define LED_PIN PINB5

void setup()
	/* Initialize serial comm port */
	/* Set output ports */
	DDRB |= (1 << LED_PIN);

void loop() 
	/* Print elapsed time during discharge cycle */
	Serial.print("Elapsed time: ");
	Serial.print(dischargeTime(), DEC);
	Serial.print(" us");
	delay(1000); /* Pause */

uint32_t dischargeTime(void) 
	/* Mark Event */
	PORTB |= (1 << LED_PIN); 
	/* Turn LED off: reverse polarity, charge capacitor */
	DDRB |= ((1 << CATHODE_PIN) | (1 << ANODE_PIN)); /* Set Anode abd Cathode pin in output mode */
	PORTB |= (1 << CATHODE_PIN); /* Cathode to VCC */
	PORTB &= ~(1 << ANODE_PIN); /* Anode to Ground */
	/* Set input port for Cathode */
	DDRB &= ~(1 << CATHODE_PIN); /* Set Cathode pin in input mode */
	PORTB &= ~(1 << CATHODE_PIN); /* Set Cathode pin in high Z mode */
	uint32_t start = micros();
	/* Wait for the cathode pin to reach the low level */
	while (((PINB >> CATHODE_PIN) & 0x01) == 0x01);
	uint32_t stop = micros();
	/* Mark Event */
	PORTB &= ~(1 << LED_PIN); 
	/* Compute elapsed time */
	uint32_t elapsedTime = (stop - start);

void blinkLed(uint16_t cycles) 
/* Blink control led */
	/* Make the led pin an output pin */
	PORTB &= ~(1 << LED_PIN); /* Turn control led off */
	for (uint8_t i = 0; i < (cycles << 1); i++)	{
		PORTB ^= (1 << LED_PIN);

The code is self explanatory. At no time the LED will glow. Do not forget to use a resistor in serie with the LED (330 Ohms will do). The built in PINB5 LED is used for tick marking the discharge time.

Here are a couple of pictures showing the oberved measurements made with a standard red LED exposed to ambiant light (rainny day!)

and an other picture with same LED capped with black foam:

You can clearly see the difference between the two plots of the test LED signal. When exposed to the light, the electrons and holes displacement increases creating a current which charges the capacitor two times faster than under darkness conditions.

Next post on same subject


  1. Didier says:

    NB: I changed the title of this series of posts from PhotoLED to I/O LED in order to avoid any confusion with the eponym brand names.

  2. blinkenlight says:

    Here is my post on how to use this approach to implement a simple camera http://blog.blinkenlight.net/experiments/measurements/led-camera/.

  3. triesna says:

    hello, I recently purchased the arduino uno.My plan will use to create DMX controller. I really need help for:

    1. I would like to create my own DMX module i/o shield that is compatible with the arduino’s mine. I need a circuit board pcb images and using the expresspcb?
    2. how to create a set of recipients that will be placed dmx on light boxes (e.g. PAR) which 9 dipswitch address, 3xlr? (Circuit and pcb Board using the expresspcb).
    3. the image signal receiver Circuit for powering led DMX RGB (Par or strip)
    4. How do you do if the arduino and dmx shield can be controlled with FREESTYLEER software?


  4. Didier says:

    1. I hope that this project is not the first one that you plan to implement with Arduino! As far as I understand, your Uno is a little piece of equipment within a pretty large project.
    2. It sounds like you have a pretty clear idea of what you want. You may write some specifications in order to help helpers to understand your needs
    3. ????
    4. Why don’t you place this question on FREESTYLEER forum?

    Add links to your messages in order to illustrate your thoughts

  5. kris says:

    Hi, is it possible to apply this technique with an addressable strip leds like http://www.adafruit.com/products/1506 or https://www.sparkfun.com/products/12025 ?

    thanks for your reply

    • Didier says:

      Hi Kris,
      No, you cannot apply this technique with addressable LEDs, as the LEDs driver sits inside the LED chip and is addressed with a digital signal. Talking about LED strips, only thise types of LED strips would possibly work: https://learn.adafruit.com/rgb-led-strips. However, driving multiple LEDs the way it is needed for I/O LED might had a lot of complexity, so that I am afraid that the final answer is no. Also, keep in mind that all standard LEDs will behave pretty differently from one to an other. I got the best results with high brightness red LEDs.

      This will not help you, but for your records, plaindsp kits (http://www.plaindsp.com/product/audio-kit/) come with a fully feature library which drives TLC5973x and WS281x RGB LED series

Leave a Reply

You must be logged in to post a comment.