LED Interfacing

LED Interfacing

In this tutorial we understand the interfacing of LED with 8051 microcontroller. Here is the first pattern to glow all LED’s connected with output  AT89C51.

 Circuit  Principle

  • The main principle of circuit is to interface LED’s to the 8051 microcontroller and performing different patterns with LED’s. Here first i have introduce a very basic operation of taking an output of AT89C51 microcontroller and interfacing it with LED’s .
  • AT89C51 is a microcontroller which belongs to family of 8051 microcontroller and it is very commonly used because it is a 8 bit device and 8 bit operation can easily performed by it. Hence output of AT89C51 is given to LED’s which have voltage drop of 1.7volts and current of 10mA to glow.

Required circuit component:

  • Microcontroller – AT89C51
  • LED’s  (8) – {D1 to D8}
  • Resistors (8) – {R1 to R8}
  • Crystal oscillators  – {11.0592 MHz}
  • Capacitors (2) -33Pf – {C1 to C2}

Circuit Designing

  • It consists of AT89C51 microcontroller, it belongs to the family of 8051 microcontroller. AT89c51 has 4kb of flash programmable and erasable read only memory and 128 bytes of RAM.
  • It supports USART communication protocol, and has 40 pins,16 bit counter/timer. The controller is connected with external crystal oscillator to pin 18 and 19 and crystal oscillator pins are connected to ground through capacitor of 33pf.
  • LED’s are directly connected to the microcontroller pins and the negative terminal of these LED’s are connected to the ground through resistor of value 330 ohm and maximum output voltage of microcontroller is 5 volts.
  • Value of resistors can be calculated by formula
    • R=(V-1.7/10mA) where v is the input voltage .
  • Different pattern of LED’s by interfacing with 8051 (AT89c51)

LED’s Switching

A light emitting diode(LED) is a two way semiconductor light source, it emits light when a suitable voltage is applied to the leads, these leads are made of semiconductor material.

Algorithm:

  • Include the preprocessor directive <reg51.h>
  • Make a delay function with void type.

  • Declare variable ‘i’ with integer type.

  • Start a loop for (i=1;i<a;i++)

  • Start main function with void return type

  • Start while loop “while(1)”> always true.

  • P2=0xFF, i.e…P2 is ON.

  • Call delay function “delay(1000)”;

  • P2=0x00; i.e…P2 is OFF.

  • Call delay function “delay(1000);

  • End loop

  • End main

Programming Example 1.

 A group of LED connected at port 2 write a C program for LED interfacing to flashing these LED continuously. 

#include<reg51.h>
void main()
{
P2=~P2; //Invert the port value and assign it again on the port
}

Note: – To see the effect of program connect the LED on port 2 and check the effect only on the Proteus or simulator of Keil C.This is practice program if you run on the real hardware then you can’t see the effect because here we don’t use the delay to see the effect. 

Programming Example 2. 

A group of LED connected at port 2 write a C program for LED interfacing to show the BCD number 0 to 255 on these LED?

#include<reg51.h>
void main()
{
          int i;
          for(i=1;i<=255;i++) //logic to generate BCD number
           P2=i;
}

Note: – To see the effect of program run it, in single step mode on the simulator of Keil C.

 

By |2018-12-14T23:06:54+00:00February 17th, 2017|8051 Projects, Programming 8051|0 Comments

You May Like




Author

This author has not yet filled in any details.
So far the author has created 4 blog entries.
February 17th, 2017

Recent Posts

Categories

For You

%d bloggers like this: