Skip to main content

How to interface 7 segment with AT89C51 ( 0-9 counting )

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 cylinderical 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 a
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 in2 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.
CommonCathode: Here common pin is cathode and connected to ground and rest
pins are connected to port of at89c51.

Here we connect 7-segment to port3 of at89c51 and will display 0-9 numeric value with
some delay. Here we will pass hex code developed by the on-off value of led in favour
to display value to port3.

                 

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=0xc0;     // hex code to display 0 on 7-segment     
13:        delay(100);     
14:        P3=0xf9;     // hex code to display 1 on 7-segment     
15:        delay(100);  
16:        P3=0xa4;     // hex code to display 2 on 7-segment     
17:        delay(100);     
18:        P3=0xb0;     // hex code to display 3 on 7-segment    
19:        delay(100);  
20:        P3=0x99;     // hex code to display 4 on 7-segment     
21:        delay(100);     
22:        P3=0x92;     // hex code to display 5 on 7-segment     
23:        delay(100);  
24:        P3=0x82;     // hex code to display 6 on 7-segment    
25:        delay(100);     
26:        P3=0xf8;     // hex code to display 7 on 7-segment   
27:        delay(100);  
28:        P3=0x80;     // hex code to display 8 on 7-segment   
29:        delay(100);     
30:        P3=0x90;     // hex code to display 9 on 7-segment    
31:        delay(100);     
32:       }  
33:     }  


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

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.

Different Stages of I2C communication

Different Stages Of I2C

Read condition data frames for I2C communication

Inter-Integrated Circuit