#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key=P2^7; //切换按键
uint num=0;
uchar code zi[]={
0x10,0x40,0x10,0x22,0xF0,0x15,0x1F,0x08,
0x10,0x14,0xF0,0x63,0x80,0x00,0x82,0x00,
0x82,0x40,0x82,0x80,0xE2,0x7F,0x92,0x00,
0x8A,0x00,0xC6,0x00,0x80,0x00,0x00,0x00,
0x10,0x40,0x10,0x22,0xF0,0x15,0x1F,0x08,
0x10,0x14,0xF0,0x63,0x80,0x00,0x82,0x00,
0x82,0x40,0x82,0x80,0xE2,0x7F,0x92,0x00,
0x8A,0x00,0xC6,0x00,0x80,0x00,0x00,0x00,
0x40,0x04,0x30,0x04,0x11,0x04,0x96,0x04,
0x90,0x04,0x90,0x44,0x91,0x84,0x96,0x7E,
0x90,0x06,0x90,0x05,0x98,0x04,0x14,0x04,
0x13,0x04,0x50,0x06,0x30,0x04,0x00,0x00,
0x04,0x00,0x04,0x00,0x04,0x08,0x04,0x18,
0x14,0x04,0x24,0x04,0xC4,0x02,0x04,0x02,
0x04,0x01,0x04,0x21,0x84,0x40,0x04,0x80,
0x04,0x40,0xFE,0x3F,0x04,0x00,0x00,0x00,
0x40,0x80,0x42,0x80,0x42,0x40,0x42,0x20,
0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,
0x43,0x40,0x62,0xC0,0x40,0x40,0x00,0x00,
0x40,0x80,0x42,0x80,0x42,0x40,0x42,0x20,
0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,
0x43,0x40,0x62,0xC0,0x40,0x40,0x00,0x00,
0x00,0x00,0xF8,0xFF,0x08,0x00,0x08,0x00,
0xCC,0x1F,0x4A,0x08,0x49,0x08,0x48,0x08,
0x48,0x08,0x48,0x08,0xE8,0x1F,0x48,0x40,
0x08,0x80,0xFC,0x7F,0x08,0x00,0x00,0x00,
0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,
0x00,0x40,0x00,0x40,0x00,0x40,0xFF,0x7F,
0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x40,
0x20,0x40,0x00,0x60,0x00,0x40,0x00,0x00
//好好学习 天天向上
};
uchar code xingming[]={
0x00,0x01,0x00,0x01,0x88,0x00,0x88,0x7F,
0x44,0x89,0x47,0x89,0x28,0x89,0x10,0x8F,
0x28,0x89,0x45,0x89,0x42,0x89,0x84,0x9F,
0x8C,0x80,0x00,0xE1,0x00,0x01,0x00,0x00,
0x00,0x01,0x00,0x01,0x88,0x00,0x88,0x7F,
0x44,0x89,0x47,0x89,0x28,0x89,0x10,0x8F,
0x28,0x89,0x45,0x89,0x42,0x89,0x84,0x9F,
0x8C,0x80,0x00,0xE1,0x00,0x01,0x00,0x00,
0x10,0x40,0x10,0x22,0xF0,0x15,0x1F,0x08,
0x10,0x14,0xF0,0x63,0x02,0x08,0xFA,0x09,
0x02,0x09,0x02,0x09,0x02,0x4D,0xFF,0x89,
0x02,0x41,0x80,0x3F,0x00,0x01,0x00,0x00,
0x10,0x40,0x10,0x22,0xF0,0x15,0x1F,0x08,
0x10,0x14,0xF0,0x63,0x02,0x08,0xFA,0x09,
0x02,0x09,0x02,0x09,0x02,0x4D,0xFF,0x89,
0x02,0x41,0x80,0x3F,0x00,0x01,0x00,0x00
};//爸爸妈妈
uchar code loveyou[]={
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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,
0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,
0x78,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*心形图案*/
};
uchar code Hello[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/* " " 0*/
0X08,0X20,0Xf8,0x3f,0x08,0x21,0x00,0x01,0x00,0x01,0x08,0x21,0Xf8,0x3f,0x08,0x20,/* "H" 1*/
0x00,0x00,0x00,0x1F,0x80,0x22,0x80,0x22,0x80,0x22,0x80,0x22,0x00,0x13,0x00,0x00,/* "e" 2*/
0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/* "l",3*/
0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/* "l",4*/
0x00,0x00,0x00,0x1F,0x80,0x20,0x80,0x20,0x80,0x20,0x80,0x20,0x00,0x1F,0x00,0x00,/* "o",5*/
0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x33,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,/* "!",6*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/* " ",7*/
};
uchar code Smile[] =
{
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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0x1F,0x3C,0x3C,0x0E,0xF7,0x06,0xEF,0xF3,0xDC,0xF3,0xB0,0x63,0xB0,0x03,0xB0,
0xF3,0xB0,0xF3,0xB8,0x03,0xDD,0x06,0xEF,0x0E,0x76,0x3C,0x3C,0xF8,0x1F,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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
//笑脸
uchar code Thanks[] =
{
// 谢
0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,
// 谢
0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,
// !
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,
0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
uchar code tian[]=
{
0x40,0x80,0x42,0x80,0x42,0x40,0x42,0x20,
0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,
0x43,0x40,0x62,0xC0,0x40,0x40,0x00,0x00,
0x40,0x80,0x42,0x80,0x42,0x40,0x42,0x20,
0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,
0x43,0x40,0x62,0xC0,0x40,0x40,0x00,0x00,
0x80,0x00,0x82,0x80,0x82,0x40,0x82,0x30,
0xFE,0x0F,0x82,0x00,0x82,0x00,0x82,0x00,
0x82,0x00,0x82,0x00,0xFE,0xFF,0x82,0x00,
0x83,0x00,0xC2,0x00,0x80,0x00,0x00,0x00,
0x00,0x04,0x00,0x02,0xC0,0x01,0x00,0x00,
0xF0,0x3F,0x00,0x40,0x01,0x40,0x02,0x40,
0x1C,0x40,0x08,0x40,0x00,0x40,0x00,0x70,
0x40,0x00,0x80,0x00,0x00,0x07,0x00,0x00
};
// 天天开心
uchar code happy[]=
{
0x00,0x00,0x80,0x40,0x60,0x40,0x38,0x40,
0x1E,0x41,0x14,0x41,0x10,0x41,0x10,0x41,
0xFF,0x7F,0xFE,0x7F,0x10,0x41,0x10,0x41,
0x90,0x41,0x18,0x41,0x10,0x60,0x00,0x40,
0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,
0xFC,0x7F,0x84,0x20,0x84,0x20,0x84,0x20,
0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,
0xFC,0xFF,0xFE,0x7F,0x04,0x00,0x00,0x00,
0x00,0x00,0xC0,0x00,0x60,0x00,0xFF,0xFF,
0xFE,0x7F,0x30,0x80,0x60,0x41,0x08,0x71,
0x08,0x3D,0xFF,0x0F,0xFE,0x07,0x08,0x0D,
0xF8,0x39,0xFC,0x71,0x08,0xE1,0x00,0x41,
0x00,0x00,0x00,0x40,0x80,0x20,0x80,0x30,
0xFE,0x1C,0xFC,0x0E,0x84,0x24,0x84,0x40,
0xFE,0xFF,0xF6,0x7F,0x82,0x00,0x83,0x02,
0xC2,0x0C,0x80,0x18,0x00,0x70,0x00,0x20
};
// 生日快乐
uchar code shenti[]={
0x00,0x40,0x00,0x42,0x00,0x42,0x00,0x22,
0xFC,0x23,0x54,0x22,0x56,0x12,0x55,0x12,
0x54,0x0A,0x54,0x46,0x54,0x82,0xFE,0x7F,
0x04,0x01,0x80,0x00,0x40,0x00,0x00,0x00,
0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x08,
0x10,0x06,0x90,0x01,0x70,0x04,0x10,0x04,
0xFF,0xFF,0x10,0x04,0x70,0x04,0x90,0x01,
0x18,0x06,0x10,0x0C,0x00,0x04,0x00,0x00,
0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x44,
0x88,0x29,0x48,0x19,0x38,0x27,0x10,0x49,
0x54,0x89,0x54,0x89,0xFF,0xFF,0x54,0x89,
0x54,0x89,0x7C,0xCD,0x10,0x49,0x00,0x00,
0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x40,
0x54,0x23,0x54,0x15,0x54,0x49,0x55,0x81,
0xFE,0x7F,0x54,0x05,0x54,0x09,0x54,0x11,
0xF4,0x29,0x46,0x64,0x44,0x20,0x00,0x00
};
// 身体健康
void delay(uint z)
{
uint x;
for(x=0;x<z;x++);
}
void display1() //显示“LOVE” 64*16像素
{
uchar i;
delay(4000);
for(i=0;i<128;i++)
{
P1=~zi[2*i];
P3=~zi[2*i+1];
delay(120);
}
}
void display2() //显示“心形图案” 64*16像素
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~xingming[2*i];
P3=~xingming[2*i+1];
delay(120);
}
}
void display3() //显示“LOVE” 64*16像素
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~loveyou[2*i];
P3=~loveyou[2*i+1];
delay(120);
}
}
void display4() //显示“Hello!” 64*16像素
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~Hello[i*2];
P3=~Hello[i*2+1];
delay(120);
}
}
void display5() //显示“笑脸图案” 64*16像素
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~Smile[i*2];
P3=~Smile[i*2+1];
delay(120);
}
}
void display6()
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~tian[i*2];
P3=~tian[i*2+1];
delay(120);
}
}
void display7()
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~happy[i*2];
P3=~happy[i*2+1];
delay(120);
}
}
void display8()
{
uchar i;
delay(4000);
for(i=0;i<64;i++)
{
P1=~shenti[i*2];
P3=~shenti[i*2+1];
delay(120);
}
}
void display9() //显示“谢谢!” 48*16像素
{
uchar i;
delay(4000);
for(i=0;i<48;i++)
{
P1=~Thanks[i*2];
P3=~Thanks[i*2+1];
delay(120);
}
}
void keyscan()
{
if(key==0)
delay(500);
if(key==0)
{
num++;
while(!key);
if(num==10)
num=1;
}
}
void display()
{
switch(num)
{
case 1: display1();break;
case 2: display2();break;
case 3: display3();break;
case 4: display4();break;
case 5: display5();break;
case 6: display6();break;
case 7: display7();break;
case 8: display8();break;
case 9: display9();break;
default :display1();
}
}
void main()
{
while(1)
{
keyscan();
display();
}
}
|