Count 0-9 on seven segment with 8051 Micro-controller using C

In this code, I am going to show you how to write code to display 0-9 on single seven segment.

Image result for seven segmen


  Pin configuration of seven segment


The compiler used Keil C51 you can download it from here . it comes with 2Kb code restrication which is ok for learners.

C code for 7 segment 

#include<reg51.h>
#define SEG_DATA P1
#define SEG_CTRL P0
   
unsigned char sev_seg[10]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef}; 

void main()
{
unsigned char j;
while(1)
{
for(j=0;j<10;j++)
{
    SEG_CTRL = 0x0f;
SEG_DATA = sev_seg[j];
delay(30000);
}
}
}

void delay(int x)
{
int i;
for(i=0;i<x;i++);
}

Build this code in Keil generate hex code and burn it using the universal burner or any other tool supported by your board.

you can also get video tutorial from here.


Thank you.