.. www.engineerscur.blogspot.com
8051 LED Interface......

8051 LED Interface

 

It is very easy to to interfacing LED(s) with 8051 micro controller.All you need is some basics of C-language & awareness of components.So, let's get start....


 All you need is...
1).  -->8051 development board.
2). --> LED(s) if not connected in dev. board than separately.
3). --> Serial communication cable.
4). -->Adapter as per dev. board.
5).  -->Software  required KEIL & FLASH MAGIC.

 Step 1.

                 First of all we have to prepare c program to manipulate LED(s).
EX.
________________________________________________________________________
#include<reg51.h>

void delay(unsigned int);
void main()
{
    int i;
    while(1)
    {
        for(i=0;i<100;i++);
        {
            P1=i;
            delay(100);
        }
    }
   
}

void delay(unsigned int a)
{
    int j;
    for(j=0;j<a;j++)
    {
         for(j=0;j<10;j++)
        {
        }
    }
}
  _______________________________________________________________________


            Now, write & compile code in KEIL.If there is any error in your program then correct it.
             If you don't know how to use KEIL & FLASH MAGIC than there are many tutorials are available on youtube.Believe me it's very easy to use.  :)


 Step 2.

             Ones your c file is ready then we need to convert it in to hex file.Which is binary file for machines.We will do it with the help of KEIL itself.

Step 3.

             When you are ready with your HEX file then we need to just install it in controller with the help of FLASH MAGIC.Again if you don't know how to use it then see tutorial on youtube.
   

Step 4.

            Connection with leds.
             Above written code is for Maximum 8 LEDs or less.It will send binary equivalent of 0-100 on controllers selected pins(here,P1).So it will send +5 V when data will be one & 0 or Ground when bit will be 0 on that pin.
           Delay function  is required because if we'll not use it then we'll not be able to see blinking LEDs.It will on-off so fast.

Ports pins                     :-       p1.0    p1.1    p1.2    p1.3    p1.4    p1.5    p1.6    p1.7

Binary value (random no.) :- 1          0       0            1        0          1        1        1
                            
               So connect LEDs +ve terminals to port 1s pins and -ve to Ground.


Step 5.

              After uploading the file(hex) on controller press reset button and leds will start blinking....

              So thats all for now wait for my next post.                       :)
             


Follow me on FB..