按下K1显示-小 按下k2显示-母 按下k3显示-猪
#include<reg51.h>
#include<intrins.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit SHCP=P3^6;
sbit STCP=P3^5;
sbit DS=P3^4;
#define k P0
u8 code ledh1[]=
{
/*-- 文字: 小 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x20,0x40,0x80,0x00,0x00,
0x08,0x04,0x03,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x01,0x0E,0x00,
};
u8 code ledh2[]=
{
/*-- 文字: 母 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x40,0xC0,0x7E,0x42,0x42,0x4A,0x72,0x42,0x42,0x42,0xFE,0x40,0x40,0x40,0x00,
0x00,0x00,0x0F,0x08,0x08,0x08,0x09,0x0E,0x48,0x88,0x48,0x3F,0x08,0x08,0x00,0x00,
};
u8 code ledh3[]=
{
/*-- 文字: 猪 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x22,0x14,0x08,0xF4,0x02,0x20,0x24,0x24,0xA4,0x7F,0x24,0x34,0x28,0x26,0x20,0x00,
0x44,0x82,0x41,0x3F,0x00,0x04,0x02,0xFF,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,
};
u8 code ledl[]=
{
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
};
void delay(u16 i)
{
while(i--);
}
void hc595bit(u8 dat1,u8 dat2,u8 dat3,u8 dat4)
{
u8 i;
for(i=0;i<8;i++)
{
DS=dat1>>7;
dat1=dat1<<1;
SHCP=0;
_nop_();
_nop_();
SHCP=1;
}
for(i=0;i<8;i++)
{
DS=dat2>>7;
dat2=dat2<<1;
SHCP=0;
_nop_();
_nop_();
SHCP=1;
}
for(i=0;i<8;i++)
{
DS=dat3>>7;
dat3=dat3<<1;
SHCP=0;
_nop_();
_nop_();
SHCP=1;
}
for(i=0;i<8;i++)
{
DS=dat4>>7;
dat4=dat4<<1;
SHCP=0;
_nop_();
_nop_();
SHCP=1;
}
STCP=0;
_nop_();
_nop_();
STCP=1;
}
void main()
{
u8 a;
k=0x0f;
while(1)
{
if(k!=0x0f)
{
delay(1000);
if(k!=0x0f)
{
switch(k)
{
case(0x01):
for(a=0;a<16;a++)
{
hc595bit(~ledl[a+16],~ledl[a],ledh1[a+16],ledh1[a]);
delay(10);
};break;
case(0x02):
for(a=0;a<16;a++)
{
hc595bit(~ledl[a+16],~ledl[a],ledh2[a+16],ledh2[a]);
delay(10);
} ;break;
case(0x04):
for(a=0;a<16;a++)
{
hc595bit(~ledl[a+16],~ledl[a],ledh3[a+16],ledh3[a]);
delay(10);
};break;
}
}
}
}
}
|