#include <REGX52.H>
sbit SCLK=P1^0;
sbit DAT=P1^2;
sbit SLCK=P1^1;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
#define uchar unsigned char
#define uint unsigned int
uchar code table[64]={//{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x02,0x80,
0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,0x08,0x10,0x10,0x0E,0x60,0x04,0x00,0x00};// 大
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
uchar code table1[64]={
0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,
0x00,0x40,0x01,0x84,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,//学
//{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
void delay(void);
uint offset;
void display_595(uchar L1,uchar L2,uchar L3,uchar L4)//
{ uchar i;
uchar j;
uchar a[3];
a[0]=L1;
a[1]=L2;
a[2]=L3;
a[3]=L4;
SLCK=0;
for(j=0;j<4;j++)
{
for(i=0;i<8;i++)//把数组中的每一个数送到移位寄存器(8位的数)
{
SCLK=0;//寄存器的时钟输入,上升沿有效
DAT=a[j]&0x80;
a[j]=a[j]<<1; //将a值左移一位
SCLK=1;
}
}
SLCK=1;
}
void main(void)
{
TMOD=0x01;
TH0=0xb1;
TL0=0xe0;
ET0=1;
EA=1;
TR0=1;
while(1)
{ uchar i;
for(i=0;i<16;i++)
{
display_595(table[offset+2*i],table[offset+2*i+1],table1[offset+2*i],table1[offset+2*i+1]);//
delay();
P2=i;
delay();
}
}
}
void delay(void)
{
uint i;
for(i=0;i<10;i++);
}
void timer0() interrupt 1 using 3
{
uchar n;
TF0=0;
TH0=0xb1;
TL0=0xe0;
if(n<20)
{
n++;
}
else
{
// offset+=2;
//if(offset>32)
// offset=0;
n=0;
}
}
全部资料51hei下载地址:
16x32点阵显示2个汉字计.zip
(48.19 KB, 下载次数: 31)
|