Home Login Sign Up Blogs & Articles Jobs Mobiles & Tablets Online Calculators Engineering Projects List Groomix Enterprises Publish your topics Ask Question About Blogs & Articles Feedback

programming

views : 180

Very simple and accurate Seven Segment Display program Code in Embedded C language

As seven segment display is used to display numeric digits, it become very important in any numeric data display in electronics device. Seven segment display is named so because numeric digit from 0 to 9 can be display by ON/OFF of segment's LED. Generally, seven segment has one more segment to indicate dot. Means, it contain 8 LEDs.

Embedded C language program Code

Note : Firstly, identify your seven segment display type i.e. Common Cathode (CC) or Common Anode (CA). Generally, it has 10 pins in a dual in-line (DIP) pakage and center pin of each side is a common pin. You can even identify its type by using LED tester.

//////////global variable declaration start
char digit_count = 1;
unsigned char DIGIT1=1;
unsigned char DIGIT2=2;
unsigned char DIGIT3=3;
unsigned char DIGIT4=4;
unsigned char SEGMENT_CODE[11]={0xBE,0x8 4,0x3D,0xAD,0x87,0xAB,0xBB ,0x8C,0xBF,0xAF,0X40};
//////////global variable declaration end////////////

//////////output assignment start
sfr SEG_DATA at P1;
sbit  SEL_DIGIT1 at P3_0_bit;
sbit  SEL_DIGIT2 at P3_1_bit;
sbit  SEL_DIGIT3 at P3_2_bit;
sbit  SEL_DIGIT4 at P3_3_bit;
void INIT_OUTPUT()
{
SEG_DATA = 0;
SEL_DIGIT1 = 0;
SEL_DIGIT2 = 0;
SEL_DIGIT3 = 0;
SEL_DIGIT4 = 0;
}
//////////output assignment end
//////////input assignment start
//////////input assignment end
////////////////// SEVEN SEGMENT DISPLAY SATRT
void _7SEG_DISPLAY() iv IVT_ADDR_ET0 ilevel 0 ics ICS_AUTO
{
TCON.B4 = 0;        //stop TIMER0 FOR TIME COUNT
if(digit_count==1)
  {
  SEL_DIGIT1 = 1;
  SEL_DIGIT2 = 0;
  SEL_DIGIT3 = 0;
  SEL_DIGIT4 = 0;
  SEG_DATA = SEGMENT_CODE[(0B00000011 & seconds)];
  }
if(digit_count==2)
  {
  SEL_DIGIT1 = 0;
  SEL_DIGIT2 = 1;
  SEL_DIGIT3 = 0;
  SEL_DIGIT4 = 0;
  SEG_DATA = SEGMENT_CODE[(0B01110000 & seconds)>>4];
  }
if(digit_count==3)
  {
  SEL_DIGIT1 = 0;
  SEL_DIGIT2 = 0;
  SEL_DIGIT3 = 1;
  SEL_DIGIT4 = 0;
  SEG_DATA = SEGMENT_CODE[0];
  }
if(digit_count==4)
  {
  SEL_DIGIT1 = 0;
  SEL_DIGIT2 = 0;
  SEL_DIGIT3 = 0;
  SEL_DIGIT4 = 1;
  SEG_DATA = SEGMENT_CODE[0];
  }
digit_count++;
if(digit_count>4)   {
  digit_count=1;
  }
TH0=0xF0;
TL0=0;
TCON.B4 = 1;        //START TIMER1 FOR TIME COUNT
}
void timer0_init()
{
TMOD=0b00000001;    //TIMER0 AS 16-BIT COUNTER
TCON.B0=1;
IE.B1=1;      //TIMER0 INTERRUPT IS ON
TH0=0;
TL0=0;
TCON.B4 = 1;        //START TIMER1 FOR TIME COUNT
IE.B7=1;            //interrupt enable
}
////////////////////// SEVEN SEGMENT DISPLAY END

////////////////////// ////////////////////////// //////////
////////////////////// ////////////////////////// //////////
////////////////////// ////////////////////////// //////////
void main() {
  Delay_ms(2000);
  timer0_init();
  while (1)                // Endless loop
  {
  Delay_ms(20);          // Wait 1 second
  }
}
////////////////////// ////////////////////////// //////////
////////////////////// ////////////////////////// //////////
////////////////////// ////////////////////////// //////////

For any query, feel free to comment below.....

Image : Seven segment display with LEDs representation

Posted By :
Mr. Unique

2016-08-09/20:51:11

Share this Page

Comments...

Please, Login to comment or reply

More :programming

programming
Arduino UNO tachometer coding with variable resistor and DC motor speed control

p

programming
Here is the code to interface 2 serial devices with AVR

p

programming
Software Uart for AVR microcontroller tested on 1200 baud rate

p

programming
ATMEL STUDIO-While loop conditioning issues

p

programming
ATMEL STUDIO-While loop is not working using interrupt incremented conditioning

p

programming
Copy and paste code for facebook share button in your websites
programming
How to program atmel 8051 family microcontroller? (step by step)
programming
Embedded program code in C language for Digital Voltmeter for AVR microcontroller
programming
Assemby program code for Automatic Door Opening System (8051 family microcontroller)
programming
Very simple and accurate Seven Segment Display program Code in Embedded C language

p

programming
Highway vehicle speed detector or checker Embedded C language code in MikroC AVR Framework also applicable for 8051 Microcontroller

p

programming
Assembly program for accurate 1 second delay function
programming
What is Embedded system programming?

Latest Updates

programming
Arduino UNO tachometer coding with variable resistor and DC motor speed control
views :167

p

programming
Here is the code to interface 2 serial devices with AVR
views :144

p

programming
Software Uart for AVR microcontroller tested on 1200 baud rate
views :724

p

programming
ATMEL STUDIO-While loop conditioning issues
views :181

p

programming
ATMEL STUDIO-While loop is not working using interrupt incremented conditioning
views :277

p

programming
Copy and paste code for facebook share button in your websites
views :284
programming
How to program atmel 8051 family microcontroller? (step by step)
views :289
programming
Embedded program code in C language for Digital Voltmeter for AVR microcontroller
views :231
programming
Assemby program code for Automatic Door Opening System (8051 family microcontroller)
views :171
programming
Very simple and accurate Seven Segment Display program Code in Embedded C language
views :180

p

programming
Highway vehicle speed detector or checker Embedded C language code in MikroC AVR Framework also applicable for 8051 Microcontroller
views :100

p

programming
Assembly program for accurate 1 second delay function
views :149
programming
What is Embedded system programming?
views :180

Reach Us From Google Map

DO MORE WITH US

PRODUCT CATEGORY