又搞左成日單片機。。編了一春鳥語。
因為初學用曬89 c51的IO口,而且程序鬼春甘長,搞左個數字時鐘。
不過用Proteus仿真,
#include <reg51.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
uint8 number[]={0x9e,0x24,
0xc,0x98,0x48,
0x40,0x1e,0x0,
0x8};
uint8 numbera[]={0x79,0x24,0x30,
0x19,0x12,0x2,
0xf8,0x0,0x10,0x40
};
uint8 numberb[]={0x79,0x24,0x30,
0x19,0x12,0x2,
0xf8,0x0,0x10,0x40
};
uint8 numberc[]={0x79,0x24,0x30,
0x19,0x12,0x2,
0xf8,0x0,0x10,0x40
};
main()
{
uint8 i,j,a,c;
uint16 counter;
P1=0x2;
P0=0x40;
P2=0x40;
P3=0x40;
TMOD=0x01;
TH0=0xb8;
TL0=0x00;
TR0=1;
while(1)
{
if (TF0==1)
{
TH0=0xb8;
TL0=0x00;
TF0=0;
counter++;
}
if(counter==1)
{
counter=0;
P1= number[i++];
}
if(i==10)
{ P1=0x2;
i=0;
P0=numbera[j++];
}
if(j==10)
{
P0=0x40;
j=0;
P2=numberb[a++];
}
if(a==10)
{
a=0;
P3=numberc[c++];
}
if(c==10)
{
P3=0x40;
c=0;
}
}
}
|