Programming: views : 2873

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.....

Embedded C language program Code
Embedded-C-language-program-Code2016-08-03_05_46_40


Share this page with your friends
share via Whatsapp

Posted By :
Mahesh Nigam
(Scientist)
2019-09-27 17:13
See Author's other Published Topics

Airtel cheating ther customers by incomplete description of recharge pack of Big companies like Airtel, also cheating their customers by providing incomplete or confusing description of their recharge plans
Big companies like Airtel, also cheating their customers by providing incomplete or confusing description of their recharge plans
साहस और धैर्य का प्रतिक कारगिल विजय दिवस  of साहस और धैर्य का प्रतिक कारगिल विजय दिवस
साहस और धैर्य का प्रतिक कारगिल विजय दिवस
Vaisakhi  of Vaisakhi
Vaisakhi
3 मार्च - विश्व वन्यजीव दिवस of 3 मार्च - विश्व वन्यजीव दिवस
3 मार्च - विश्व वन्यजीव दिवस
1 मार्च- विश्व प्रशंसा दिवस of 1 मार्च- विश्व प्रशंसा दिवस
1 मार्च- विश्व प्रशंसा दिवस
1 मार्च- विश्व नागरिक सुरक्षा दिवस of 1 मार्च- विश्व नागरिक सुरक्षा दिवस
1 मार्च- विश्व नागरिक सुरक्षा दिवस
1 मार्च - शून्य भेदभाव दिवस of 1 march शून्य भेदभाव दिवस
1 march शून्य भेदभाव दिवस
करती रही of पूरा नही बस थोड़ा सा ही समझा होता ....
पूरा नही बस थोड़ा सा ही समझा होता ....
वैलेंटाइन of वैलेंटाइन डे मनाने के पीछे एक रोचक तथ्य व 7 से 14 तक वैलेंटाइन सेलिब्रेट करने की सूची
वैलेंटाइन डे मनाने के पीछे एक रोचक तथ्य व 7 से 14 तक वैलेंटाइन सेलिब्रेट करने की सूची
National Test Agency of UGC NET December 2023 results and download its subject wise cut-off
UGC NET December 2023 results and download its subject wise cut-off
परीक्षा पे चर्चा  of परीक्षा पे चर्चा युवाओं के लिए तनाव मुक्त माहौल बनाने के लिए प्रधान मंत्री नरेंद्र मोदी के नेतृत्व में बड़े आंदोलन - 'एग्जाम वॉरियर्स' का हिस्सा है।
परीक्षा पे चर्चा युवाओं के लिए तनाव मुक्त माहौल बनाने के लिए प्रधान मंत्री नरेंद्र मोदी के नेतृत्व में बड़े आंदोलन - 'एग्जाम वॉरियर्स' का हिस्सा है।

Peoples

Comments...

Write Your Comment

Related to Programming

Latest topics




More Categories
latest mobile phones ireps.gov.in irctc.co.in Working Principle Viral Discussion True Love quotes True Love Today is Celebrated For Tips for better life Tips and Hacks Technology News Teachers Day Quotes Study Materials Self Motivating Quotes Science Sad Lines (Sayeri) Romantic shayari quotes Robotics Reviews Results Questions_and_Answers Programming Problem Resolved PHP Codes PCB Design Online Works New Year Quotes Shayari Status My World My Responsibilities Motivational lines Mobile Issues Microcontrollers Lucknow Local News Latest Technology Iphone Homeopathy Historical place in India Heart Touching Love Quotes Health Good Night Quotes Good Morning Quotes GeM.gov.in GST portal Funny Lines (Sayeri) Friendship Quotes Food Recipes Exam Time Table Engineering Project Ideas Electronics Electronic and electrical project making ideas Electricals Educations Desh Bhakti Shayeri Criminal Love Cricket News Corona Updates Christmas Quotes Shayari Status CBSE Updates/Circulars Breaking News Breaking Heart Shayeri Break Up Lines (Sayeri) BirthDay Wishes Best kitchen Tips Best Valentine quotes Shayeri Beauty Hacks Basic Knowledges Attitude quotes shayari Attitude quotes Attitude quotes Assembly Election 2022

MORE

Programming >
latest mobile phones >
ireps.gov.in >
irctc.co.in >
Working Principle >
Viral Discussion >
True Love quotes >
True Love >
Today is Celebrated For >
Tips for better life >
Tips and Hacks >
Technology News >
Teachers Day Quotes >
Study Materials >
Self Motivating Quotes >
Science >
Sad Lines (Sayeri) >
Romantic shayari quotes >
Robotics >
Reviews >
Results >
Questions_and_Answers >
Problem Resolved >
PHP Codes >
PCB Design >
Online Works >
New Year Quotes Shayari Status >
My World My Responsibilities >
Motivational lines >
Mobile Issues >
Microcontrollers >
Lucknow Local News >
Latest Technology >
Iphone >
Homeopathy >
Historical place in India >
Heart Touching Love Quotes >
Health >
Good Night Quotes >
Good Morning Quotes >
GeM.gov.in >
GST portal >
Funny Lines (Sayeri) >
Friendship Quotes >
Food Recipes >
Exam Time Table >
Engineering Project Ideas >
Electronics >
Electronic and electrical project making ideas >
Electricals >
Educations >
Desh Bhakti Shayeri >
Criminal Love >
Cricket News >
Corona Updates >
Christmas Quotes Shayari Status >
CBSE Updates/Circulars >
Breaking News >
Breaking Heart Shayeri >
Break Up Lines (Sayeri) >
BirthDay Wishes >
Best kitchen Tips >
Best Valentine quotes Shayeri >
Beauty Hacks >
Basic Knowledges >
Attitude quotes shayari >
Attitude quotes >
Attitude quotes >
Assembly Election 2022 >

Peoples

Latest Comments