Home > other >  Novice for single chip microcomputer, Yin four digital tube on the left two digital tube with the ri
Novice for single chip microcomputer, Yin four digital tube on the left two digital tube with the ri

Time:12-02

# include
# define uchar unsigned char
# define uint unsigned int
# define ziwei P2
# define ziduan P0
Uchar code Led []={xa4 xc0 0, 0 xf9, 0, 0 xb0, 0 x99, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90};
Uchar code hang []={0 x01, 0 x02, 0 x00 to 0 x00};
Uchar buffer [4].
Uint count;
Uint oldCount;
Unsigned char I;

Void delay ()
{unsigned char (I); for(i=0; i<0 x40; i++);
}
Void num ()
{
Buffer [0]=count/1000% 10;
Buffer [1]=count/100% 10;

}
Void xianshi ()
{
uchar i;
for(i=0; i<4. I++)
{
Ziwei=~ hang [I];
Led [buffer ziduan=[I]];
Delay ();
Ziduan=0 XFF;
}
}
Void main ()
{count=0;
OldCount=oldCount + 1;
TMOD=0 x01;
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
EA=1;
ET0=1;
i=0;
TR0=1;
While (1)
{if (oldCount!=count)
{
OldCount=count;
Num ();
} xianshi ();
}
}
Void time0_int (void) interrupt 1 {
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
i++;
If (i>=50) {
i=0;
If (count>=19) count=0;

count++;

}
}

This code are going to change how can we achieve the left two digital tube to add
  • Related