LED Interfacing with 8051


LED stands for Light Emitting Diode which is one of the most useful electronic component in our day to day life. It is widely used for indicator and display devices. It is a special kind of PN junction diode which can emit light when it is forward biased. LED finds various amazing uses for decoration also. LED Cube, Infinite mirror etc. can provide excellent look to your dream home. In this article, we will explain basics of LED and how to interface it with 8051 micro-controller. After that you can make series for Diwali decoration on your own. So let’s blink ….!!!

Construction

LED is very much similar to the PN junction diode. It has two layers made of P and N type of semiconductor material. Density of impurity has been added such that the frequency of emitted energy when the diode is forward biased, falls in the range of visible light. Two terminals called as anode and cathode are taken out from P and N type materials respectively.

Construction of LED

Construction of LED

The entire assembly is kept in a reflective cavity to direct the emitted light into a particular direction. Casing of transparent plastic has been provided to protect the LED from dust, humidity etc.

Working

Let us denote voltage at anode and cathode terminals as VA and VK respectively. When (VA - VK) >Vf, LED is forward biased and electrons of cathode regions combines with holes of anode regions. Here Vf indicates the knee voltage of LED. In this process, the energy in terms of light is emitted. Thus when LED is forward biased, it emits the light of different wavelength which depends on the construction and doping level of the material.

Intensity of light depends upon the current flowing through the LED. Generally, a constant current source is used with LED to control the light intensity when LED is forward biased. This is achieved by connecting a resistor in series with LED. It provides the easiest way to control intensity of emitted light.

Simple circuit of LED is as shown in figure.

Basic Circuit of LED

Basic Circuit of LED

When the switch is closed, battery voltage VBAT is applied at anode of LED. Cathode of LED is grounded through resistor so LED is forward biased and current flows through the LED. Value of current is given by the formula

I= (VBAT- Vf)/R

Here, VBAT is the voltage of battery in volt

Vf is the knee voltage of voltage drop across LED when its forward biased in volt

R is the value of resistor in ohm

Here is the tricky thing…!! How to select the value of resistor..!!

To begin the calculations, first we need to understand a few basic things.

  1. Forward Current (IF)

It indicates the maximum value of current which can flow through the LED. If current higher than this value flows through LED for a longer duration, it can damage the LED.

  1. Peak Forward Current (IFP)

If current higher than IF flows for a short duration, LED can bear with it. Maximum value of current which can flow through LED for a short duration is denoted as IFP. This is the maximum value of current which can flow through LED without damaging it. While designing the circuit, we must take care that current doesn’t exceed this value in any situation otherwise LED will be damaged permanently.

Vf also plays an important role for LED based circuits. Value of Vf depends upon the color of light. It also varies depending upon the material, doping level and manufacturing process. LEDs of same manufacturing batch can also have slight difference in forward biased voltage drop.

Here is the approximate values of forward biased voltage drop for LEDs. For exact values, we need to refer the datasheet of LED which is in use.

Color Wavelength [nm] Voltage drop [ΔV]
Infrared λ > 760 ΔV < 1.63
Red 610 < λ < 760 1.63 < ΔV < 2.03
Orange 590 < λ < 610 2.03 < ΔV < 2.10
Yellow 570 < λ < 590 2.10 < ΔV < 2.18
Green 500 < λ < 570 1.9 < ΔV < 4.0
Blue 450 < λ < 500 2.48 < ΔV < 3.7
Violet 400 < λ < 450 2.76 < ΔV < 4.0
Purple Multiple types 2.48 < ΔV < 3.7
Ultraviolet λ < 400 3 < ΔV < 4.1
Pink Multiple types ΔV ~ 3.3
White Broad spectrum 2.8 < ΔV < 4.2

Let’s understand calculations for proper understanding.

Power Supply VBAT= 5V

Forward Current If= 10mA

Forward biased voltage drop Vf= 1.8V (RED LED)

Resistor R= (VBAT- Vf)/ If = (5-1.8) / (10*0.001) = (3.2* 1000)/10= 320 ohm

As 320 ohm is non-standard value, we must consider the nearby higher value of resistor which is 330 ohm.

Thus current If = (5-1.8)/330= 9.69mA

Power supplied by battery= VBAT * If = 5*9.69 = 48.45 mW

Power consumption by LED= Vf * If = 1.8*9.69 =17.44 mW

Power loss across resistor= I2*R = (9.69)2 * 330 = 31.01 mW

It is clear from the example that most of the power (64% in this case) is lost across the resistor. To reduce this power loss, we can connect LEDs in series.

Series connection of LEDs

We can connect LEDs in series to reduce voltage drop across the resistor as shown in circuit.

Power Supply VBAT= 5V

Forward Current If= 10mA

Forward biased voltage drop across LED1 Vf1= 1.8V (RED LED)

Forward biased voltage drop across LED2 Vf2= 1.8V (RED LED)

Multiple LEDs in series

Multiple LEDs in series

In this case, voltage across the resistor will be VR= VBAT-Vf1- Vf2

Thus value of Resistor R= (VBAT- Vf1- Vf2)/ If = (5-1.8-1.8) / (10*0.001) = (1.4* 1000)/10= 140 ohm

As 140 ohm is non-standard value, we must consider the nearby higher value of resistor which is 150 ohm.

Thus current If = (5-1.8-1.8)/150= 9.33mA

Power supplied by battery= VBAT * If = 5*9.33 = 46.67 mW

Power consumption by LED1= Vf * If = 1.8*9.33 =16.8 mW

Power consumption by LED2= Vf * If = 1.8*9.33 =16.8 mW

Power loss across resistor= I2*R = (9.33)2 * 150 = 13.07 mW

It is clear from the example that power consumption by a resistor has been reduced to 13.07 mW instead of 31.01 mW in case of a single LED.

 

We can use the same logic for more number of LEDs also but we have to make sure that the total voltage drop across LEDs is less than the supply voltage. If total voltage drop across LEDs increase than the supply voltage, LED’s light intensity will start to decreases and eventually, all LEDs will be turned OFF.

In general if all the LEDs are of same type, then calculations becomes easy. Equations for n numbers of LEDs connected in series are given below.

  1. Resistor R= (VBAT – n*Vf)/If
  2. Power consumption by each LED = Vf * If
  3. Power consumption by resistor= If2 * R

 

To interface LEDs with 8051, we will connect a resistor of 330 ohm in series with LED. We can connect LEDs in two ways shown below.

1.Common Cathode configuration

In this configuration, cathode of LED is grounded through a resistor as shown in figure. Anode is connected to a GPIO pin of 8051.

LED in Common Cathode Mode

LED in Common Cathode Mode

When controller pin is kept at logic 1, Anode of LED gets 5V from a controller pin and cathode of LED is grounded through a resistor. As a result LED is forward biased and forward current flows through it making it ‘ON’ . When we write logic 0 to GPIO pin, LED is reversed biased because anode is grounded via GPIO oin and it is turned off.

So in simple language, Logic 1= LED ON & Logic 0 =LED OFF

2. Common Anode Configuration

In this configuration, Anode of LED is connected to 5V power supply and cathode is connected to a GPIO pin via 330 ohm resistor as shown in below image.

LED in Common Anode Mode

LED in Common Anode Mode

When controller pin is kept at logic 1, cathode gets 5V supply from controller pin. As anode is also at 5V level, LED is reversed biased and no current can flow from it hence LED is turned off. When controller pin is kept at logic 0, cathode gets connected to ground. As anode is at 5V and cathode is grounded, LED is forward biased and current flows through it hence LED is turned ON.

So in simple language, Logic 0= LED ON & Logic 1 =LED OFF

 

So now let us connect LEDs with all Ports as shown in circuit diagram and generate various patterns on them.

LED Interfacing with 8051

LED Interfacing with 8051

Please log in to view code.

You may also like...

Leave a Reply

Specify Facebook App ID and Secret in Super Socializer > Social Login section in admin panel for Facebook Login to work

Specify LinkedIn Client ID and Secret in Super Socializer > Social Login section in admin panel for LinkedIn Login to work

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