Skip to main content

How to interface LED with AT89C51 ( all on-off )

hi, how are you today



Let's learn how to interface a led with our baby (8051uC)

Description

 This article helps you to understand the concept behind LED interfacing and its programming with AT89C51 microcontroller. Here I am going to demonstrate you the principle used behind led blinking. How a group of LED's provide you an image of different-different patterns will be easy to understand, once you are clear with this concept.
        Till date LED's are most widely used electronic component as an indicator that helps us to understand the different-different scenarios about the state of any electronic device. LED's come in different-different sizes i.e. 1.8mm, 3mm, 5mm etc. with many shapes i.e. round, square, cylindrical etc. in single or multi color. 

Operation: Operation of LED is simply and they usually have a voltage drop of 1.7V. Most commonly used LED's requires 10mA-20mA current by applying 3-12V dc. Normally we
use 220Ω resistance when applying 5V and 2.2KΩ for 12V.

You can calculate the value of resistance by the below mentioned formula
                                   V=IR                                   

Here we are going to connect 8 LED's to Port 3 of AT89C51 and we will learn how to control the blinking of led alternatively. First all led,s will on and then after some delay they all will off.
                 

Programming

1:  #include<reg51.h>      // header file  
2:  void delay(int time)      // function to generate delay  
3:     {  
4:     int i,j;  
5:     for(i=0;i<=time;i++) // i will run from 0 to user defined value  
6:     for(j=0;j<=1275;j++); // j will run from 0 to 1275 "time" times  
7:     }  
8:  void main()         // main function  
9:     {  
10:      while(1)       // while(1)used to provide continuous loop  
11:       {  
12:        P3=0x00;    // all pins set to 0 of port 3  
13:        delay(100);  // delay function called and i will run 0-100  
14:        P3=0xff;    // all pins set to 1 of port 3  
15:        delay(100);  // delay function called and i will run 0-100  
16:       }  
17:     }  

For enhance concept just visit www.salahtutorials.com
Hope you all like this post and I wish this must be useful for you.

Thanks :)

Comments

Translate to your language

Popular posts from this blog

Different Stages of I2C communication

Different Stages Of I2C

How to import Pygame in pycharm

hi, how are you today

Working demonstration of UART communication using 2 8051 uController on Proteus with Embedded C code.

Here we are going to use 2 at89c51 uControllers just to understand UART communication in 8051.