Introduction

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

Components Required

  • 8051 Microcontroller – 1
  • 8051 Program Dumper- 1
  • LED – 1
  • Resistor 10k ohm – 1
  • Breadboard – 1
  • Jumper wires

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

  • Never connect an LED directly to a battery or power supply!
  • It will be destroyed almost instantly because too much current will pass through and burn it out.
  • LEDs must have a resistor in series to limit the current to a safe value, for quick testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or less.

LED GlowingCalculating 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

  • Select the LED’s as Output in the programming since these are output devices for Micro controller(initial value 0-Output , 1-input)
  • Write the logic for Toggling of LEDS

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

By Devilal

Leave a Reply

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