MORE RELATED

GROOMIX INFO
Blogs & Articles
MENU
. . .

programming

views : 131

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

More :programming

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

p

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

p

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

p

programming
ATMEL STUDIO-While loop conditioning issues
views :134

p

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

p

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

p

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

p

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

Latest Updates

Breaking News
Best internet Recharge Plans than jio..!
views :103
Engineering Project Ideas
Vehicle Theft Protection Using Gsm
views :140
Engineering Project Ideas
DTMF Controlled Robot or Mobile Controlled Robot
views :83
Engineering Project Ideas
Digital Clock With Home Appliances Control Using Microcontroller
views :81
Engineering Project Ideas
Cooking Monitor
views :107
Engineering Project Ideas
Boundary Security System(Wireless)
views :93
Engineering Project Ideas
Automatic Garage Parking System
views :107
programming
Arduino UNO tachometer coding with variable resistor and DC motor speed control
views :108
Engineering Project Ideas
Employee Details Recording Interface synopsis
views :114
Engineering Project Ideas
Footstep Power Generation
views :90

---More To Do---

This pages is developed to give users a genuine web materials of all types throughout the world. Many articles, by experts are publishing here, every hours. You can publish your topics as well as you can comment on all posted topics and learn more. Many types of topics are published here like Technology based ( Electronics, Electricals, Mechanicals, civil engineering, computer science, programming and software development, Assemply language codings), Health like medicine, healthy diets, Homeopathy etc) and many types of latest news updates.


All content, design, and layout are Copyright © 2016 - Digital Photography Review All Rights Reserved. Reproduction in whole or part in any form or medium without specific written permission is prohibited.

MORE TO DO