a program displaying 00 to 08 using a seven segment diaplay

#include<reg51.h>
//unsigned int INT0
sbit WAVE=P1^0;

unsigned int cnt;
void timer0()


{
WAVE = ~WAVE;
}
void timer1()
{
cnt++;
P2=cnt;
P3=cnt;
}

void t0delay(void);

sbit led2=P3;
sbit t=P3^6;
sbit a=P2^0;
sbit b=P2^1;
sbit c=P2^2;
sbit d=P2^3;
sbit e=P2^4;
sbit f=P2^5;
sbit g=P2^6;
sbit h=P2^7;

void zero();
void one();
void two();
void three();
void four();
void five();
void six();
void seven();
void eight();

void main()
{
P2=0x00;
P3=0x00;

while(1)
{

P3=0x00;
t=1;
zero();
t0delay();
one();
t0delay();
two();
t0delay();
three();
t0delay();
four();
t0delay();
five();
t0delay();
six();
t0delay();
seven();
t0delay();
eight();
t0delay();


}

}

void zero()
{
a=b=c=d=e=f=0;
g=1;
}
void one()
{
b=c=0;
a=d=e=f=g=h=1;
}
void two()
{
a=b=g=d=e=0;
c=f=h=1;
}
void three()
{
a=b=g=c=d=0;
e=f=h=1;
}
void four()
{
b=c=f=g=0;
a=d=e=h=1;
}
void five()
{
a=f=g=c=d=0;
b=e=h=1;
}
void six()
{
a=f=e=d=c=g=0;
b=h=1;
}
void seven()
{
a=b=c=0;
d=e=f=g=h=1;
}
void eight()
{
a=b=c=d=e=f=g=0;
}


void t0delay(void)
{
unsigned int x;
for(x=0;x<=8;x++)
{

cnt=0;
TMOD=0x41;
TL0=98;
TH0=19;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
}
the code is working well but i don't have an idea on how to make timer1 start counting. that is assigning tho tlo
Topic archived. No new replies allowed.