Interfacing of LED with 8051

Updated on 2017/08/11 11:23


Interfacing of LED with 8051

Introduction of LED

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p–n junction diode that emits light when activated.[ When a suitable voltage is applied to the leads, electrons are able to recombine with electron holes within the device, releasing energy in the form of photons. This effect is called electroluminescence, and the color of the light (corresponding to the energy of the photon) is determined by the energy band gap of the semiconductor.

When operated in a forward biased direction Light Emitting Diodes are semiconductor devices that convert electrical energy into light energy.


Light Emitting Diode Colours

So how does a light emitting diode get its color? Unlike normal signal diodes which are made for detection or power rectification, and which are made from either Germanium or Silicon semiconductor materials, Light Emitting Diodes are made from exotic semiconductor compounds

Different LED compounds emit light in specific regions of the visible light spectrum and therefore produce different intensity levels.


The LED is to be connected in a forward bias condition across a power supply it should be current limited using a series resistor to protect it from excessive current flow. Never connect an LED directly to a battery or power supply as it will be destroyed almost instantly because too much current will pass through and burn it out.

LED Series Resistor Circuit

The series resistor value RS is calculated by simply using Ohm´s Law, by knowing the required forward current IF of the LED, the supply voltage VS across the combination and the expected forward voltage drop of the LED, VF at the required current level, the current limiting resistor is calculated as:


An amber coloured LED with a forward volt drop of 2 volts is to be connected to a 5.0v stabilised DC power supply. Using the circuit above calculate the value of the series resistor required to limit the forward current to less than 10mA. Also calculate the current flowing through the diode if a 100Ω series resistor is used instead of the calculated first.

series resistor required at 10mA:


Interfacing of LED with 8051

An LED can be interfaced with 8051 for various purpose. The Port Pins are configured in the output direction. So, once the Logic "1" is the at O/P pin, then an LED will be turned "ON". And when Logic "0" is given the LED will be turned "OFF".

Simply: Logic "1" -> 5V DC to output pin

             Logic "0" -> 0 V to output pin.

So, as discussed in earlier, the LED with common cathode mode can be connected with 8051 along with a resistor.

Thus, using the current limiting resistor, the LED will blink according to the written program in 8051.

Below in diagram simple example is shown. Here, from P1, 4 pins are interfaced with LED's. (P1.0, P1.1, P1.2 & P1.3)

For eg: Write a Assembly program to Blink 4 LED's continuously which are connected to Port P1.


The accumulator is loaded with value & then it is moved to Port. So, According to 1 & 0 the LED's will Blink.



Assembly Source Code:


Video Proteus Simulation


  • Created and edited by Prof Harshad.Lokhande, Sinhgad's NBNSTIC, Ambegaon(Bk), Pune
  • WikiNote Foundation
Created by Vishal E on 2017/08/04 12:46