MEVIHUB

LED Interfacing with 8051

Introduction

Hi everyone, in this article we will see how to interface LED with 8051 using Keil IDE and proteus.

Components Required

LED

Light Emitting Diode. These are the semiconductor light sources, Commonly used LEDs will have a cut-off voltage of 1.7V and current of 10mA. When an LED is applied with its required voltage and current it glows with full intensity. The Light Emitting Diode is similar to the normal PN diode but it emits energy in the form of light. The colour of light depends on the band gap of the semiconductor.

Connecting LED to Micro Controller

Calculating Resistance for connecting to LED

LEDs cut-off voltage of 1.7V

Max current of 10mA.

                          V=I*R

                 R=V/I

                 R=(Vcc-Vcutoff)/Imax

                  =(5-1.7)/10*10^-3

                 =330 Ohms

LEDS Interfacing to Micro Controller

Device Mapping:

                 The Device Mapping is the complete Schematic Diagram of the interfacing. In this we will connect the Led’s to our required port and we will write the programming according to the circuit.

Programming for LED’s interfacing with AT89C51

Code

#include <AT89X51.H>

/* Renaming port2 as LEDS */
sfr LEDS = 0XA0;

/*Delay function to Observe Led blink Clearly*/
void Delay(unsigned int t)
{
unsigned int i;
while(t--)
for(i=0;i<1257;i++);
}

main()
{
/* Selecting LEDS as Output */

LEDS=0X00;

/*Starting Super Loop */

while(1)
{
LEDS = 0XFF;// Making Leds high
Delay(10);
LEDS = 0X00;// Making Leds Low
Delay(10);
}
}

Thanks for reading for any assistance or doubts comment below

Download Code
Exit mobile version