#include <STC12C5A60S2.H>
#include <intrins.h>
typedef unsigned int u16;
typedef unsigned char u8;
sbit DU = P2^0; //数码管段选
sbit WE = P2^1; //数码管位选
sbit CS88 = P2^2; //8X8点阵使能
sbit LCDEN=P2^5;
u8 code duan0[8][8]={{0x00,0x3C,0x42,0x42,0x42,0x3C,0x00,0x00},{0x3C,0x42,0x42,0x42,0x3C,0x00,0x00,0x00},
{0x42,0x42,0x42,0x3C,0x00,0x00,0x00,0x3C}, {0x42,0x42,0x3C,0x00,0x00,0x00,0x3C,0x42},
{0x42,0x3C,0x00,0x00,0x00,0x3C,0x42,0x42},{0x3C,0x00,0x00,0x00,0x3C,0x42,0x42,0x42},
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x3C},{0x00,0x00,0x3C,0x42,0x42,0x42,0x3C,0x00}}; //数字0的段选
u8 code wei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //位选
void delay(u16 c)
{
u8 a,b;
for(;c>0;c--)
for(b=142;b>0;b--)
for(a=2;a>0;a--);
}
void main()
{
u8 i,j;
u8 num;
while(1)
{
for(i=0;i<8;i++)
{
num=40;
while (num--)
{
for(j=0;j<8;j++)
{
DU=1;
P0=duan0[i][j];//取显示数据
DU=0;
CS88=1;
P0=wei[j]; //取段码
CS88=0;
delay(10); //扫描间隙延时
}
}
delay(100);
}
}
}
|