bobparihar
New Member
i am doing a project in which i have to show counting from 0 to 99 on two multiplexed seven segments connected to a single port of 8051 ie. P2
my code is
the problem here is i am not getting the desired output on simulation..first the ones place shows and it increments after some delay the tens place shows and then goes to off.. though it shows counting from 0-99 but not in a desired way..
my code is
C:
#include<reg51.h>
sbit a=P3^0; // to on off seven segment
sbit b=P3^1; // " " " " " (same as above)
void main()
{
unsigned char ar[]={0x3F,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned int i,j,k;
while(1)
{
for(i=0;i<100;i++)
{
for(j=0;j<30;j++)
{
a=0; // on the 7 seg at tenth place
b=1; // off the 7 seg at ones place
P2=ar[i/10]; // sending 0-9 to port 2 to 7 seg
for(k=0;k<1275;k++); // delay
a=1; // off 7 seg at tenth place
b=0; // on seven seg at ones place
P2=ar[i%10];
for(k=0;k<1275;k++); // delay
}
for(k=0;k<30000;k++); // large delay for increment of number at ones place
}
}
}
Last edited by a moderator: