Skip to main content

How to interface 7 segment with AT89C51 to display 0-99 using decoders....


hi, how are you today



Let's learn how to interface a 7-segment with our baby (8051uC)

Description

 This article helps you to understand the concept behind the interfacing
of 7-segment and its programming with AT89C51 microcontroller. 7-segment is a device
that is combination of 7 rectangular led that will display a number as programmed with
and one cylindrical led that acts as a decimal when required. Here I will demonstrate
the logic of displaying numeric value 0-9 on 7-segment.
It is used to display any numeric data on any device, it can display single digit at any
particular time.So the no of digits you want to display for any value,you have to use
same no of 7-segments.

7-Segments are available in 2 configurations: COMMON ANODE & COMMON CATHODE
Common Anode: Here common pin is anode and connected to +5V dc and rest pins are
connected to port of at89c51.
Common Cathode: Here common pin is cathode and connected to ground and rest pins are
connected to port of at89c51.

Here we connect two 7-segments to a single port with BCD to Binary decoders.
7447 for common anode and 7448 for common cathode.
Here we will pass hex code developed by the on-off value of led in favour
to display value to port3.

Programming

Header file and delay function


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:     }  

0-99 increasing order followed by header file and delay function
1:  void main()         // main function  
2:     {  
3:     int m;  
4:     m=0x00;  
5:     while(1)       // while(1)used to provide continuous loop  
6:      {  
7:       P3=m;  
8:       delay(100);  
9:       m++;  
10:       delay(100);  
11:       if(m==0x0a||m==0x1a||m==0x2a||m==0x3a||m==0x4a||m==0x5a||m==0x6a||m==0x7a||m==0x8a)  
12:       m=m+6;  
13:       if(m==0x9a)  
14:       m=0x00;  
15:      }  
16:     }  

0-99 decreasing order followed by header file and delay function
1:  void main()         // main function  
2:     {  
3:     int m;  
4:     m=0x99;  
5:     while(1)       // while(1)used to provide continuous loop  
6:      {  
7:       P3=m;  
8:       delay(100);  
9:       m--;  
10:       delay(100);  
11:       if(m==0x0f||m==0x1f||m==0x2f||m==0x3f||m==0x4f||m==0x5f||m==0x6f||m==0x7f||m==0x8f)  
12:       m=m-6;  
13:       if(m==0x00)  
14:        {  
15:         delay(100);  
16:         m=0x99;  
17:        }  
18:      }  
19:     }  

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.